tout 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1dd26fe372240267e97718a8a6a66279c2482b37
4
+ data.tar.gz: 5d7e155fef8dd2893d7dc416a3b77abf1fd33bbf
5
+ SHA512:
6
+ metadata.gz: eabb2f6f7701f576a80f12ff119df5af728a8d4ba3e36cbb3af94e8820b0eb643caa1e80e68d2d51e5dbff65a75562bceb5f245a506c8b44d6b53dc33de0c5eb
7
+ data.tar.gz: 9a253fac5991eb8bbc3adf58e7adb735606b4b45f61c116329e39a51dd04909bd7f7aa012a27481ba13b900fc2ab390afee2468743b0e84879ab5e5baff80f28
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tout.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Aaron Gough
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # Tout
2
+
3
+ Tout is a small helper for altering the visibility of methods while testing them. This allows classes to be structured with normal public/private methods while still maintaining full test coverage.
4
+
5
+ Tout allows a private method to be made public only for the duration of the test group, it sets the method back to private at the end of the example group to avoid any possible side effects.
6
+
7
+ ## Usage
8
+
9
+ Tout allows the easy and safe testing of private methods via the `publicize` helper like so:
10
+
11
+ ```ruby
12
+ publicize(class, :method_name)
13
+ ```
14
+
15
+ Here it is in use in a small test suite:
16
+
17
+ ```ruby
18
+ class NormalClass
19
+ def public_foo
20
+ "public"
21
+ end
22
+
23
+ private
24
+
25
+ def private_foo
26
+ "private"
27
+ end
28
+ end
29
+
30
+ describe NormalClass do
31
+ describe "#private_foo"
32
+ publicize(described_class, :private_foo)
33
+
34
+ it "returns 'private'" do
35
+ expect(described_class.private_foo).to eq("private")
36
+ end
37
+ end
38
+ end
39
+ ```
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ ```ruby
46
+ gem 'tout'
47
+ ```
48
+
49
+ And then execute:
50
+
51
+ $ bundle
52
+
53
+ Or install it yourself as:
54
+
55
+ $ gem install tout
56
+
57
+ After the gem is installed setup Tout in your RSpec config like so:
58
+
59
+ ```ruby
60
+ RSpec.configure do |config|
61
+ config.extend(Tout)
62
+ end
63
+ ```
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
68
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ require "tout/version"
2
+
3
+ module Tout
4
+ def publicize(klass, method)
5
+ method_already_public = klass.method_defined?(method)
6
+ private_method_defined = klass.private_method_defined?(method)
7
+
8
+ before(:each) do
9
+ raise "Cannot publicize #{klass.name}##{method} as it is already public." if method_already_public
10
+ raise "Cannot publicize #{klass.name}##{method} no private method by that name exists." unless private_method_defined
11
+
12
+ klass.send(:public, method) if private_method_defined && !method_already_public
13
+ end
14
+
15
+ after(:each) do
16
+ klass.send(:private, method) if private_method_defined && !method_already_public
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Tout
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tout/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tout"
8
+ spec.version = Tout::VERSION
9
+ spec.authors = ["Aaron Gough"]
10
+ spec.email = ["aaron@aarongough.com"]
11
+
12
+ spec.summary = %q{Allow the easy testing of private methods.}
13
+ spec.description = %q{Allow the easy testing of private methods.}
14
+ spec.homepage = "https://github.com/aarongough/tout"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.14"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Gough
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Allow the easy testing of private methods.
56
+ email:
57
+ - aaron@aarongough.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/tout.rb
69
+ - lib/tout/version.rb
70
+ - tout.gemspec
71
+ homepage: https://github.com/aarongough/tout
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.10
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Allow the easy testing of private methods.
95
+ test_files: []