rr 1.2.0 → 3.0.3

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.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +58 -0
  3. data/Gemfile +1 -8
  4. data/README.md +9 -13
  5. data/Rakefile +30 -6
  6. data/lib/rr/class_instance_method_defined.rb +1 -1
  7. data/lib/rr/double.rb +28 -10
  8. data/lib/rr/double_definitions/double_definition.rb +39 -16
  9. data/lib/rr/double_definitions/double_definition_create.rb +5 -5
  10. data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +10 -4
  11. data/lib/rr/double_definitions/strategies/strategy.rb +29 -8
  12. data/lib/rr/double_definitions/strategies/verification/mock.rb +8 -2
  13. data/lib/rr/double_matches.rb +4 -3
  14. data/lib/rr/expectations/any_argument_expectation.rb +4 -4
  15. data/lib/rr/expectations/argument_equality_expectation.rb +43 -5
  16. data/lib/rr/injections/double_injection.rb +85 -26
  17. data/lib/rr/injections/method_missing_injection.rb +36 -9
  18. data/lib/rr/keyword_arguments.rb +21 -0
  19. data/lib/rr/method_dispatches/base_method_dispatch.rb +22 -5
  20. data/lib/rr/method_dispatches/method_dispatch.rb +21 -10
  21. data/lib/rr/method_dispatches/method_missing_dispatch.rb +14 -5
  22. data/lib/rr/recorded_call.rb +9 -3
  23. data/lib/rr/recorded_calls.rb +17 -7
  24. data/lib/rr/space.rb +15 -5
  25. data/lib/rr/version.rb +1 -1
  26. data/lib/rr/without_autohook.rb +2 -1
  27. data/rr.gemspec +5 -0
  28. data/spec/suites.yml +1 -15
  29. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +18 -18
  30. data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +9 -9
  31. data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +21 -21
  32. data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +4 -4
  33. data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +31 -21
  34. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +0 -12
  35. data/spec/suites/rspec_2/unit/space_spec.rb +4 -3
  36. metadata +61 -13
  37. data/lib/rr/proc_from_block.rb +0 -11
  38. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +0 -133
  39. data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
  40. data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +0 -142
  41. data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +0 -149
  42. data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +0 -173
  43. data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
@@ -7,20 +7,20 @@ module RR
7
7
  attr_reader :expectation
8
8
 
9
9
  before do
10
- @expectation = ArgumentEqualityExpectation.new(boolean)
10
+ @expectation = ArgumentEqualityExpectation.new([boolean], {})
11
11
  end
12
12
 
13
13
  describe "#wildcard_match?" do
14
14
  context "when passed a Boolean" do
15
15
  it "returns true" do
16
- expect(expectation).to be_wildcard_match(true)
17
- expect(expectation).to be_wildcard_match(false)
16
+ expect(expectation).to be_wildcard_match([true], {})
17
+ expect(expectation).to be_wildcard_match([false], {})
18
18
  end
19
19
  end
20
20
 
21
21
  context "when not passed a Boolean" do
22
22
  it "returns false" do
23
- expectation.should_not be_wildcard_match(:not_a_boolean)
23
+ expectation.should_not be_wildcard_match([:not_a_boolean], {})
24
24
  end
25
25
  end
26
26
  end
@@ -11,70 +11,80 @@ module Expectations
11
11
 
12
12
  describe "#exact_match?" do
13
13
  before do
14
- @expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash))
14
+ @expectation = ArgumentEqualityExpectation.new([hash_including(expected_hash)], {})
15
15
  end
16
16
 
17
17
  it "returns true when passed in a HashIncluding matcher with the same hash" do
18
- expect(expectation).to be_exact_match(RR::WildcardMatchers::HashIncluding.new(expected_hash))
18
+ expect(expectation).to be_exact_match([RR::WildcardMatchers::HashIncluding.new(expected_hash)],
19
+ {})
19
20
  end
20
21
 
21
22
  it "returns false when passed in a HashIncluding matcher with a different argument list" do
22
- expectation.should_not be_exact_match(RR::WildcardMatchers::HashIncluding.new(:foo => 1))
23
+ expectation.should_not be_exact_match([RR::WildcardMatchers::HashIncluding.new(:foo => 1)],
24
+ {})
23
25
  end
24
26
 
25
27
  it "returns false otherwise" do
26
- expectation.should_not be_exact_match("hello")
27
- expectation.should_not be_exact_match(:hello)
28
- expectation.should_not be_exact_match(1)
29
- expectation.should_not be_exact_match(nil)
30
- expectation.should_not be_exact_match(true)
31
- expectation.should_not be_exact_match()
28
+ expectation.should_not be_exact_match(["hello"], {})
29
+ expectation.should_not be_exact_match([:hello], {})
30
+ expectation.should_not be_exact_match([1], {})
31
+ expectation.should_not be_exact_match([nil], {})
32
+ expectation.should_not be_exact_match([true], {})
33
+ expectation.should_not be_exact_match([], {})
32
34
  end
33
35
  end
34
36
 
35
37
  describe "#wildcard_match?" do
36
38
  before do
37
- @expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash))
39
+ @expectation = ArgumentEqualityExpectation.new([hash_including(expected_hash)],
40
+ {})
38
41
  end
39
42
 
40
43
  it "returns true when hash contains same key/values as the expectation" do
41
- expect(expectation).to be_wildcard_match(expected_hash)
44
+ expect(expectation).to be_wildcard_match([expected_hash], {})
42
45
  end
43
46
 
44
47
  it "returns true when hash contains at least expectation's key/values" do
45
- expect(expectation).to be_wildcard_match(expected_hash.merge(:oregon => "Salem"))
48
+ expect(expectation).to be_wildcard_match([expected_hash.merge(:oregon => "Salem")],
49
+ {})
46
50
  end
47
51
 
48
52
  it "returns true when passed the same hash, even after the original is modified" do
49
53
  original_expected_hash = expected_hash.clone
50
54
  expected_hash[:texas] = nil
51
- expect(expectation).to be_wildcard_match(original_expected_hash)
55
+ expect(expectation).to be_wildcard_match([original_expected_hash], {})
52
56
  end
53
57
 
54
58
  it "returns true even if one of the expectation's values is nil" do
55
- expectation = ArgumentEqualityExpectation.new(hash_including(:foo => nil))
56
- expect(expectation).to be_wildcard_match({:foo => nil})
59
+ expectation = ArgumentEqualityExpectation.new([hash_including(:foo => nil)],
60
+ {})
61
+ expect(expectation).to be_wildcard_match([{:foo => nil}],
62
+ {})
57
63
  end
58
64
 
59
65
  it "returns false when hash matches only some required key/values" do
60
- expectation.should_not be_wildcard_match({:texas => "Austin"})
66
+ expectation.should_not be_wildcard_match([{:texas => "Austin"}],
67
+ {})
61
68
  end
62
69
 
63
70
  it "returns false when hash matches all the keys but not all the values" do
64
- expectation.should_not be_wildcard_match({:texas => "Austin", :maine => "Portland"})
71
+ expectation.should_not be_wildcard_match([{:texas => "Austin", :maine => "Portland"}],
72
+ {})
65
73
  end
66
74
 
67
75
  it "returns false when passed a hash that matches all values but not all keys" do
68
- expectation.should_not be_wildcard_match({:texas => "Austin", :georgia => "Augusta"})
76
+ expectation.should_not be_wildcard_match([{:texas => "Austin", :georgia => "Augusta"}],
77
+ {})
69
78
  end
70
79
 
71
80
  it "returns true when an exact match" do
72
- expect(expectation).to be_wildcard_match(hash_including(expected_hash))
81
+ expect(expectation).to be_wildcard_match([hash_including(expected_hash)],
82
+ {})
73
83
  end
74
84
 
75
85
  it "returns false when not passed correct number of arguments" do
76
- expectation.should_not be_wildcard_match()
77
- expectation.should_not be_wildcard_match(:a, :b)
86
+ expectation.should_not be_wildcard_match([], {})
87
+ expectation.should_not be_wildcard_match([:a, :b], {})
78
88
  end
79
89
  end
80
90
  end
@@ -231,12 +231,6 @@ module RR
231
231
  end
232
232
 
233
233
  describe "being called" do
234
- it "defines __rr__original_{method_name} to be the lazily created method" do
235
- subject.foobar
236
- expect((!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar})).to be_true
237
- expect(subject.__rr__original_foobar).to eq :original_foobar
238
- end
239
-
240
234
  it "calls the lazily created method and returns the injected method return value" do
241
235
  original_return_value = nil
242
236
  stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
@@ -383,12 +377,6 @@ module RR
383
377
  end
384
378
 
385
379
  describe "being called" do
386
- it "defines __rr__original_{method_name} to be the lazily created method" do
387
- subject.foobar
388
- expect((!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar})).to be_true
389
- expect(subject.__rr__original_foobar).to eq :original_foobar
390
- end
391
-
392
380
  it "calls the lazily created method and returns the injected method return value" do
393
381
  original_return_value = nil
394
382
  stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
@@ -13,9 +13,10 @@ module RR
13
13
  object = Object.new
14
14
  method_name = :to_s
15
15
  arguments = []
16
- space.record_call(object, method_name, arguments, lambda {})
16
+ keyword_arguments = {}
17
+ space.record_call(object, method_name, arguments, keyword_arguments, lambda {})
17
18
  expect(space.recorded_calls[0]).to eq \
18
- RR::RecordedCall.new(object, method_name, arguments, lambda {})
19
+ RR::RecordedCall.new(object, method_name, arguments, keyword_arguments, lambda {})
19
20
  end
20
21
  end
21
22
 
@@ -202,7 +203,7 @@ module RR
202
203
 
203
204
  it "should clear the #recorded_calls" do
204
205
  object = Object.new
205
- space.record_call(object, :to_s, [], nil)
206
+ space.record_call(object, :to_s, [], {}, nil)
206
207
 
207
208
  space.reset
208
209
  expect(space.recorded_calls).to eq RR::RecordedCalls.new([])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -10,8 +10,64 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-29 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2021-06-22 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: test-unit
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: test-unit-rr
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
15
71
  description: RR is a test double framework that features a rich selection of double
16
72
  techniques and a terse syntax.
17
73
  email:
@@ -93,10 +149,10 @@ files:
93
149
  - lib/rr/integrations/minitest_active_support.rb
94
150
  - lib/rr/integrations/rspec/invocation_matcher.rb
95
151
  - lib/rr/integrations/rspec_2.rb
152
+ - lib/rr/keyword_arguments.rb
96
153
  - lib/rr/method_dispatches/base_method_dispatch.rb
97
154
  - lib/rr/method_dispatches/method_dispatch.rb
98
155
  - lib/rr/method_dispatches/method_missing_dispatch.rb
99
- - lib/rr/proc_from_block.rb
100
156
  - lib/rr/recorded_call.rb
101
157
  - lib/rr/recorded_calls.rb
102
158
  - lib/rr/space.rb
@@ -154,7 +210,6 @@ files:
154
210
  - spec/suites/rspec_2/helper.rb
155
211
  - spec/suites/rspec_2/integration/minitest_4_spec.rb
156
212
  - spec/suites/rspec_2/integration/minitest_spec.rb
157
- - spec/suites/rspec_2/integration/rspec_2_spec.rb
158
213
  - spec/suites/rspec_2/spec_helper.rb
159
214
  - spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb
160
215
  - spec/suites/rspec_2/support/mixins/double_definition_creator_helpers.rb
@@ -215,7 +270,6 @@ files:
215
270
  - spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb
216
271
  - spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb
217
272
  - spec/suites/rspec_2/unit/integrations/rspec_spec.rb
218
- - spec/suites/rspec_2/unit/proc_from_block_spec.rb
219
273
  - spec/suites/rspec_2/unit/rr_spec.rb
220
274
  - spec/suites/rspec_2/unit/space_spec.rb
221
275
  - spec/suites/rspec_2/unit/spy_verification_spec.rb
@@ -233,10 +287,6 @@ files:
233
287
  - spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb
234
288
  - spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb
235
289
  - spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb
236
- - spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb
237
- - spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb
238
- - spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb
239
- - spec/suites/rspec_2_rails_4/spec_helper.rb
240
290
  - spec/support/adapter.rb
241
291
  - spec/support/adapter_tests/base.rb
242
292
  - spec/support/adapter_tests/minitest.rb
@@ -312,11 +362,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
362
  - !ruby/object:Gem::Version
313
363
  version: '0'
314
364
  requirements: []
315
- rubyforge_project:
316
- rubygems_version: 2.5.1
365
+ rubygems_version: 3.3.0.dev
317
366
  signing_key:
318
367
  specification_version: 4
319
368
  summary: RR is a test double framework that features a rich selection of double techniques
320
369
  and a terse syntax.
321
370
  test_files: []
322
- has_rdoc:
@@ -1,11 +0,0 @@
1
- module RR
2
- if RUBY_VERSION =~ /^1.8/
3
- class ProcFromBlock < Proc
4
- def ==(other)
5
- Proc.new(&self) == other
6
- end
7
- end
8
- else
9
- ProcFromBlock = Proc
10
- end
11
- end
@@ -1,133 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
- describe 'Integration with RSpec 2' do
4
- include IntegrationTests::RubyRSpec
5
-
6
- def configure_project_generator(project_generator)
7
- super
8
- project_generator.configure do |project|
9
- project.rspec_version = 2
10
- end
11
- end
12
-
13
- def self.including_the_adapter_manually_works
14
- specify "including the adapter manually works" do
15
- project = generate_project do |project|
16
- project.add_to_prelude <<-EOT
17
- RSpec.configure do |c|
18
- c.mock_with :rr
19
- end
20
- EOT
21
- end
22
- project.add_test_file do |file|
23
- file.add_working_test_case_with_adapter_tests do |test_case|
24
- test_case.add_to_body <<-EOT
25
- it 'loads the correct adapters' do
26
- assert_adapters_loaded #{adapters_that_should_be_loaded.inspect}
27
- end
28
- EOT
29
- end
30
- end
31
- result = project.run_tests
32
- result.should be_success
33
- result.should_not have_errors_or_failures
34
- end
35
- end
36
-
37
- def self.rr_hooks_into_the_test_framework_automatically
38
- specify "RR hooks into the test framework automatically" do
39
- project = generate_project
40
- project.add_test_file do |file|
41
- file.add_working_test_case
42
- end
43
- result = project.run_tests
44
- result.should be_success
45
- result.should_not have_errors_or_failures
46
- end
47
- end
48
-
49
- context 'when Bundler is autorequiring RR' do
50
- def configure_project_generator(project_generator)
51
- super
52
- project_generator.configure do |project|
53
- project.autorequire_gems = true
54
- end
55
- end
56
-
57
- def adapters_that_should_be_loaded
58
- [:RSpec2]
59
- end
60
-
61
- including_the_adapter_manually_works
62
- end
63
-
64
- context 'when RR is being required manually' do
65
- def configure_project_generator(project_generator)
66
- super
67
- project_generator.configure do |project|
68
- project.autorequire_gems = false
69
- end
70
- end
71
-
72
- def adapters_that_should_be_loaded
73
- [:RSpec2]
74
- end
75
-
76
- rr_hooks_into_the_test_framework_automatically
77
- including_the_adapter_manually_works
78
-
79
- specify "when RR raises an error it raises a failure not an exception" do
80
- project = generate_project
81
- project.add_test_file do |file|
82
- file.add_test_case do |test_case|
83
- test_case.add_test <<-EOT
84
- object = Object.new
85
- mock(object).foo
86
- EOT
87
- end
88
- end
89
- result = project.run_tests
90
- result.should fail_with_output(/1 failure/)
91
- end
92
-
93
- specify "it is still possible to use a custom RSpec-2 adapter" do
94
- project = generate_project do |project|
95
- project.add_to_prelude <<-EOT
96
- module RR
97
- module Adapters
98
- module RSpec2
99
- include RRMethods
100
-
101
- def setup_mocks_for_rspec
102
- RR.reset
103
- end
104
-
105
- def verify_mocks_for_rspec
106
- RR.verify
107
- end
108
-
109
- def teardown_mocks_for_rspec
110
- RR.reset
111
- end
112
-
113
- def have_received(method = nil)
114
- RR::Adapters::Rspec::InvocationMatcher.new(method)
115
- end
116
- end
117
- end
118
- end
119
-
120
- RSpec.configure do |c|
121
- c.mock_with RR::Adapters::RSpec2
122
- end
123
- EOT
124
- end
125
- project.add_test_file do |file|
126
- file.add_test_case_with_adapter_tests
127
- end
128
- result = project.run_tests
129
- result.should be_success
130
- result.should_not have_errors_or_failures
131
- end
132
- end
133
- end