rspec-context-private 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 911537603f2444e88adc6459d3eb2a4869630779
4
+ data.tar.gz: 5a0c62bbed324382d13d6ab8b0571e2e1fa99d7f
5
+ SHA512:
6
+ metadata.gz: 6c71cb95f9b987c542f081a8068a5582c66589ad4ab8cc45871ba9df18486cef4b4f2940761de77904d1e1f8d7b2097b44f6dfb160122ba54b5b3fbfcb335b08
7
+ data.tar.gz: 9e2df81392be8265f34eb70c695408d14adcc90c16573c7756929a04b4885d647c9adc1c2207ffe7c001b0332533ca1ae54b2c924b86675acf96aec188f6d200
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-context-private.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sean Devine
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ ## rspec-context-private
2
+
3
+ Writing Ruby? :thumbsup: Using RSpec? :thumbsup: Feeling naughty? :scream: Want to test some private methods? :astonished:
4
+
5
+
6
+ ```ruby
7
+ # Gemfile
8
+ gem 'rspec-context-private'
9
+ ```
10
+
11
+ ```ruby
12
+ # example.rb
13
+ class Example
14
+ private def foo
15
+ 'bar'
16
+ end
17
+ end
18
+ ```
19
+
20
+ ```ruby
21
+ # example_spec.rb
22
+ describe Example do
23
+ describe 'some private methods', :private do
24
+ expect(subject.foo).to eq 'bar'
25
+ end
26
+ end
27
+ ```
28
+
29
+ ### Why would you EVER!? want to test a private method?
30
+
31
+ If you're using some flavor of TDD, you might want to test some private methods that you develop along the way. Maybe you'll delete them later? Or maybe you're a crazy rebel :stuck_out_tongue_closed_eyes: and you'll keep the tests around and make your code difficult to refactor and disappoint the Internet!
32
+
33
+ Whatever your reason - this gem makes it more pleasant to test private methods.
34
+
35
+ ### Credits
36
+
37
+ Written by [@barelyknown](http://twitter.com/barelyknown).
38
+
39
+ This gem uses [RSpec's shared context feature](https://www.relishapp.com/rspec/rspec-core/docs/example-groups/shared-context).
40
+
41
+ The idea for the gem came from [this old blog post](http://blog.jayfields.com/2007/11/ruby-testing-private-methods.html) by Jay Fielder.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require 'rspec/core'
2
+
3
+ require_relative 'private/version'
4
+ require_relative 'private/private'
5
+
6
+ module RSpec
7
+ module Context
8
+ module Private
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ RSpec.shared_context 'private', private: true do
2
+
3
+ before :all do
4
+ described_class.class_eval do
5
+ @original_private_instance_methods = private_instance_methods
6
+ public *@original_private_instance_methods
7
+ end
8
+ end
9
+
10
+ after :all do
11
+ described_class.class_eval do
12
+ private *@original_private_instance_methods
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,7 @@
1
+ module RSpec
2
+ module Context
3
+ module Private
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/context/private/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-context-private"
8
+ spec.version = RSpec::Context::Private::VERSION
9
+ spec.authors = ["Sean Devine"]
10
+ spec.email = ["barelyknown@icloud.com"]
11
+ spec.summary = %q{RSpec shared context to make private methods temporarily public.}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/barelyknown/rspec-context-private"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ class Example
4
+ private def foo; end
5
+ end
6
+
7
+ describe Example do
8
+
9
+ describe 'without the private shared context' do
10
+ it 'cannot test private methods' do
11
+ expect{subject.foo}.to raise_error NoMethodError
12
+ end
13
+ end
14
+
15
+ describe 'with the private shared context', :private do
16
+ it 'can test private methods' do
17
+ expect{subject.foo}.not_to raise_error
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,5 @@
1
+ require 'rspec/context/private'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-context-private
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Devine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-24 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: RSpec shared context to make private methods temporarily public.
56
+ email:
57
+ - barelyknown@icloud.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/rspec/context/private.rb
69
+ - lib/rspec/context/private/private.rb
70
+ - lib/rspec/context/private/version.rb
71
+ - rspec-context-private.gemspec
72
+ - spec/lib/rspec/context/private/private_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/barelyknown/rspec-context-private
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: RSpec shared context to make private methods temporarily public.
98
+ test_files:
99
+ - spec/lib/rspec/context/private/private_spec.rb
100
+ - spec/spec_helper.rb