bogus 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/Guardfile +1 -3
  5. data/Guardfile.cucumber +0 -2
  6. data/README.md +1 -1
  7. data/bogus.gemspec +3 -1
  8. data/features/changelog.md +11 -0
  9. data/features/configuration/fake_ar_attributes.feature +2 -2
  10. data/features/contract_tests/contract_tests_mocks.feature +5 -5
  11. data/features/contract_tests/contract_tests_spies.feature +1 -1
  12. data/features/contract_tests/contract_tests_stubs.feature +6 -6
  13. data/features/contract_tests/custom_overwritten_class.feature +4 -4
  14. data/features/contract_tests/return_value_contracts.feature +2 -2
  15. data/features/fakes/anonymous_doubles.feature +5 -5
  16. data/features/fakes/duck_types.feature +9 -9
  17. data/features/fakes/fake_objects.feature +31 -8
  18. data/features/fakes/global_fake_configuration.feature +5 -5
  19. data/features/fakes/replacing_classes.feature +5 -5
  20. data/features/readme.md +5 -5
  21. data/features/safe_stubbing/argument_matchers.feature +23 -10
  22. data/features/safe_stubbing/safe_mocking.feature +1 -1
  23. data/features/safe_stubbing/safe_stubbing.feature +1 -1
  24. data/features/safe_stubbing/spies.feature +7 -7
  25. data/lib/bogus.rb +1 -0
  26. data/lib/bogus/core_ext.rb +22 -0
  27. data/lib/bogus/fakes/fake.rb +2 -1
  28. data/lib/bogus/fakes/method_stringifier.rb +1 -0
  29. data/lib/bogus/mocking_dsl.rb +4 -0
  30. data/lib/bogus/stubbing/has_overwritten_methods.rb +28 -10
  31. data/lib/bogus/stubbing/have_received_matcher.rb +4 -2
  32. data/lib/bogus/stubbing/matchers/any_args.rb +9 -0
  33. data/lib/bogus/stubbing/matchers/matches_argument.rb +11 -0
  34. data/lib/bogus/stubbing/{any_args.rb → matchers/with_arguments.rb} +0 -6
  35. data/lib/bogus/stubbing/overwrites_methods.rb +6 -1
  36. data/lib/bogus/stubbing/undefined_return_value.rb +4 -0
  37. data/lib/bogus/support.rb +11 -0
  38. data/lib/bogus/version.rb +1 -1
  39. data/spec/bogus/clean_ruby_spec.rb +1 -1
  40. data/spec/bogus/configuration_spec.rb +2 -2
  41. data/spec/bogus/contracts/adds_contract_verification_spec.rb +10 -10
  42. data/spec/bogus/contracts/adds_recording_spec.rb +4 -4
  43. data/spec/bogus/contracts/interactions_repository_spec.rb +15 -15
  44. data/spec/bogus/contracts/proxy_class_spec.rb +7 -7
  45. data/spec/bogus/contracts/records_double_interactions_spec.rb +1 -1
  46. data/spec/bogus/contracts/verifies_contracts_spec.rb +3 -3
  47. data/spec/bogus/fakes/base_class_identifier_spec.rb +1 -1
  48. data/spec/bogus/fakes/class_methods_spec.rb +4 -5
  49. data/spec/bogus/fakes/converts_name_to_class_spec.rb +3 -3
  50. data/spec/bogus/fakes/copies_classes_spec.rb +20 -16
  51. data/spec/bogus/fakes/creates_fakes_spec.rb +6 -6
  52. data/spec/bogus/fakes/creates_fakes_with_stubbed_methods_spec.rb +16 -15
  53. data/spec/bogus/fakes/fake_ar_attributes_spec.rb +3 -3
  54. data/spec/bogus/fakes/fake_configuration_spec.rb +16 -16
  55. data/spec/bogus/fakes/fake_registry_spec.rb +2 -2
  56. data/spec/bogus/fakes/fake_spec.rb +1 -1
  57. data/spec/bogus/fakes/fakes_classes_spec.rb +4 -4
  58. data/spec/bogus/fakes/faking_factories_spec.rb +4 -4
  59. data/spec/bogus/fakes/frozen_fakes_spec.rb +4 -4
  60. data/spec/bogus/fakes/instance_methods_spec.rb +5 -5
  61. data/spec/bogus/fakes/makes_ducks_spec.rb +3 -3
  62. data/spec/bogus/fakes/makes_substitute_methods_spec.rb +1 -1
  63. data/spec/bogus/fakes/overwriten_classes_spec.rb +3 -3
  64. data/spec/bogus/fakes/overwrites_classes_spec.rb +2 -2
  65. data/spec/bogus/fakes/registers_created_fakes_spec.rb +3 -3
  66. data/spec/bogus/fakes/resets_overwritten_classes_spec.rb +3 -3
  67. data/spec/bogus/fakes/stubbing_new_method_on_fake_class_spec.rb +25 -0
  68. data/spec/bogus/mocking_dsl_spec.rb +36 -36
  69. data/spec/bogus/ruby_2_1_support_spec.rb +38 -0
  70. data/spec/bogus/ruby_2_support_spec.rb +14 -64
  71. data/spec/bogus/stubbing/anything_spec.rb +5 -5
  72. data/spec/bogus/stubbing/double_spec.rb +2 -2
  73. data/spec/bogus/stubbing/have_received_matcher_spec.rb +11 -6
  74. data/spec/bogus/stubbing/interaction_spec.rb +7 -7
  75. data/spec/bogus/stubbing/multi_stubber_spec.rb +2 -2
  76. data/spec/bogus/stubbing/overwrites_methods_spec.rb +8 -8
  77. data/spec/bogus/stubbing/record_interactions_spec.rb +3 -3
  78. data/spec/bogus/stubbing/shadow_spec.rb +28 -28
  79. data/spec/bogus/stubbing/stubbing_existing_methods_on_fakes_spec.rb +50 -0
  80. data/spec/bogus/stubbing/tracks_existence_of_test_doubles_spec.rb +2 -2
  81. data/spec/bogus/stubbing/undefined_return_value_spec.rb +2 -2
  82. data/spec/spec_helper.rb +6 -1
  83. data/spec/support/shared_examples_for_keyword_arguments.rb +63 -0
  84. metadata +160 -160
  85. data/Gemfile.lock +0 -146
@@ -14,13 +14,13 @@ describe Bogus::OverwritesClasses do
14
14
  it "overwrites nested classes" do
15
15
  overwrites_classes.overwrite('SampleOuterModule::SampleModule::SampleClass', new_class)
16
16
 
17
- SampleOuterModule::SampleModule::SampleClass.should equal(new_class)
17
+ expect(SampleOuterModule::SampleModule::SampleClass).to equal(new_class)
18
18
  end
19
19
 
20
20
  it "overwrites top level classes" do
21
21
  overwrites_classes.overwrite('SampleOuterModule', new_class)
22
22
 
23
- SampleOuterModule.should equal(new_class)
23
+ expect(SampleOuterModule).to equal(new_class)
24
24
  end
25
25
  end
26
26
 
@@ -16,18 +16,18 @@ describe Bogus::RegistersCreatedFakes do
16
16
  it "registers the fakes created by creates_fakes" do
17
17
  registers_created_fakes.create(:foo, as: :instance) { Object }
18
18
 
19
- fake_registry.should have_received.store(:foo, :the_fake)
19
+ expect(fake_registry).to have_received.store(:foo, :the_fake)
20
20
  end
21
21
 
22
22
  it "tracks the created fakes for purposes of mock expectations" do
23
23
  registers_created_fakes.create(:foo, as: :instance) { Object }
24
24
 
25
- double_tracker.should have_received.track(:the_fake)
25
+ expect(double_tracker).to have_received.track(:the_fake)
26
26
  end
27
27
 
28
28
  it "returns the created fake" do
29
29
  fake = registers_created_fakes.create(:foo, as: :instance) { Object }
30
30
 
31
- fake.should == :the_fake
31
+ expect(fake).to eq :the_fake
32
32
  end
33
33
  end
@@ -16,11 +16,11 @@ describe Bogus::ResetsOverwrittenClasses do
16
16
  end
17
17
 
18
18
  it "overwrites back all of the overwritten classes" do
19
- overwrites_classes.should have_received.overwrite('Foo', :foo)
20
- overwrites_classes.should have_received.overwrite('Bar', :bar)
19
+ expect(overwrites_classes).to have_received.overwrite('Foo', :foo)
20
+ expect(overwrites_classes).to have_received.overwrite('Bar', :bar)
21
21
  end
22
22
 
23
23
  it "clears the overwritten classes" do
24
- overwritten_classes.should have_received.clear
24
+ expect(overwritten_classes).to have_received.clear
25
25
  end
26
26
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Stubbing .new on fake class" do
4
+ class ExampleForStubbingNew
5
+ end
6
+
7
+ include Bogus::MockingDSL
8
+
9
+ it "allows stubbing new on a class" do
10
+ fake_class = fake(ExampleForStubbingNew, as: :class)
11
+ stub(fake_class).new { :stubbed_value }
12
+
13
+ instance = fake_class.new
14
+
15
+ expect(instance).to eq(:stubbed_value)
16
+ end
17
+
18
+ it "returns fake instances when nothing is stubbed" do
19
+ fake_class = fake(ExampleForStubbingNew, as: :class)
20
+
21
+ instance = fake_class.new
22
+
23
+ expect(instance).to be_an_instance_of(fake_class)
24
+ end
25
+ end
@@ -30,25 +30,25 @@ describe Bogus::MockingDSL do
30
30
  it "allows stubbing the existing methods" do
31
31
  Stubber.stub(baz).foo("bar") { :return_value }
32
32
 
33
- baz.foo("bar").should == :return_value
33
+ expect(baz.foo("bar")).to eq :return_value
34
34
  end
35
35
 
36
36
  it "can stub method with any parameters" do
37
37
  Stubber.stub(baz).foo(Stubber.any_args) { :default_value }
38
38
  Stubber.stub(baz).foo("bar") { :foo_value }
39
39
 
40
- baz.foo("a").should == :default_value
41
- baz.foo("b").should == :default_value
42
- baz.foo("bar").should == :foo_value
40
+ expect(baz.foo("a")).to eq :default_value
41
+ expect(baz.foo("b")).to eq :default_value
42
+ expect(baz.foo("bar")).to eq :foo_value
43
43
  end
44
44
 
45
45
  it "can stub method with some wildcard parameters" do
46
46
  Stubber.stub(baz).hello(Stubber.any_args) { :default_value }
47
47
  Stubber.stub(baz).hello("welcome", Stubber.anything) { :greeting_value }
48
48
 
49
- baz.hello("hello", "adam").should == :default_value
50
- baz.hello("welcome", "adam").should == :greeting_value
51
- baz.hello("welcome", "rudy").should == :greeting_value
49
+ expect(baz.hello("hello", "adam")).to eq :default_value
50
+ expect(baz.hello("welcome", "adam")).to eq :greeting_value
51
+ expect(baz.hello("welcome", "rudy")).to eq :greeting_value
52
52
  end
53
53
 
54
54
  it "does not allow stubbing non-existent methods" do
@@ -63,7 +63,7 @@ describe Bogus::MockingDSL do
63
63
 
64
64
  Bogus.after_each_test
65
65
 
66
- ExampleFoo.bar("John").should == "Hello John"
66
+ expect(ExampleFoo.bar("John")).to eq "Hello John"
67
67
  end
68
68
  end
69
69
 
@@ -74,25 +74,25 @@ describe Bogus::MockingDSL do
74
74
  it "allows verifying that fakes have correct interfaces" do
75
75
  the_fake.foo("test")
76
76
 
77
- the_fake.should Stubber.have_received.foo("test")
77
+ expect(the_fake).to Stubber.have_received.foo("test")
78
78
  end
79
79
 
80
80
  it "does not allow verifying on non-existent methods" do
81
81
  expect {
82
- the_fake.should Stubber.have_received.bar("test")
82
+ expect(the_fake).to Stubber.have_received.bar("test")
83
83
  }.to raise_error(NameError)
84
84
  end
85
85
 
86
86
  it "does not allow verifying on methods with a wrong argument count" do
87
87
  expect {
88
- the_fake.should Stubber.have_received.foo("test", "test 2")
88
+ expect(the_fake).to Stubber.have_received.foo("test", "test 2")
89
89
  }.to raise_error(ArgumentError)
90
90
  end
91
91
 
92
92
  it "allows spying on methods with optional parameters" do
93
93
  the_fake.with_optional_args(123)
94
94
 
95
- the_fake.should Stubber.have_received.with_optional_args(123)
95
+ expect(the_fake).to Stubber.have_received.with_optional_args(123)
96
96
  end
97
97
  end
98
98
 
@@ -102,16 +102,16 @@ describe Bogus::MockingDSL do
102
102
 
103
103
  object.foo('test')
104
104
 
105
- object.should Stubber.have_received.foo("test")
105
+ expect(object).to Stubber.have_received.foo("test")
106
106
  end
107
107
 
108
108
  it "allows spying on methods with optional parameters" do
109
109
  object = ExampleFoo.new
110
110
  Stubber.stub(object).with_optional_args(123) { 999 }
111
111
 
112
- object.with_optional_args(123).should == 999
112
+ expect(object.with_optional_args(123)).to eq 999
113
113
 
114
- object.should Stubber.have_received.with_optional_args(123)
114
+ expect(object).to Stubber.have_received.with_optional_args(123)
115
115
  end
116
116
 
117
117
  class ClassWithMatches
@@ -124,7 +124,7 @@ describe Bogus::MockingDSL do
124
124
 
125
125
  fake.matches?("foo")
126
126
 
127
- fake.should Bogus.have_received.matches?("foo")
127
+ expect(fake).to Bogus.have_received.matches?("foo")
128
128
  end
129
129
 
130
130
  class PassesSelfToCollaborator
@@ -141,7 +141,7 @@ describe Bogus::MockingDSL do
141
141
 
142
142
  object.hello(fake)
143
143
 
144
- fake.should Bogus.have_received.foo(object)
144
+ expect(fake).to Bogus.have_received.foo(object)
145
145
  end
146
146
  end
147
147
 
@@ -157,7 +157,7 @@ describe Bogus::MockingDSL do
157
157
  it "allows mocking on methods with optional parameters" do
158
158
  Mocker.mock(baz).with_optional_args(1) { :return }
159
159
 
160
- baz.with_optional_args(1).should == :return
160
+ expect(baz.with_optional_args(1)).to eq :return
161
161
 
162
162
  expect { Bogus.after_each_test }.not_to raise_error
163
163
  end
@@ -165,7 +165,7 @@ describe Bogus::MockingDSL do
165
165
  it "allows mocking with anything" do
166
166
  Mocker.mock(baz).hello(1, Bogus::Anything) { :return }
167
167
 
168
- baz.hello(1, 2).should == :return
168
+ expect(baz.hello(1, 2)).to eq :return
169
169
 
170
170
  expect { Bogus.after_each_test }.not_to raise_error
171
171
  end
@@ -173,7 +173,7 @@ describe Bogus::MockingDSL do
173
173
  it "allows mocking the existing methods" do
174
174
  Mocker.mock(baz).foo("bar") { :return_value }
175
175
 
176
- baz.foo("bar").should == :return_value
176
+ expect(baz.foo("bar")).to eq :return_value
177
177
 
178
178
  expect { Bogus.after_each_test }.not_to raise_error
179
179
  end
@@ -246,7 +246,7 @@ describe Bogus::MockingDSL do
246
246
 
247
247
  stub(greeter).greet("Jake") { "Hello Jake" }
248
248
 
249
- greeter.greet("Jake").should == "Hello Jake"
249
+ expect(greeter.greet("Jake")).to eq "Hello Jake"
250
250
  end
251
251
 
252
252
  it "creates objects that can be mocked" do
@@ -254,13 +254,13 @@ describe Bogus::MockingDSL do
254
254
 
255
255
  mock(greeter).greet("Jake") { "Hello Jake" }
256
256
 
257
- greeter.greet("Jake").should == "Hello Jake"
257
+ expect(greeter.greet("Jake")).to eq "Hello Jake"
258
258
  end
259
259
 
260
260
  it "creates objects with some methods stubbed by default" do
261
261
  greeter = fake(greet: "Hello Jake")
262
262
 
263
- greeter.greet("Jake").should == "Hello Jake"
263
+ expect(greeter.greet("Jake")).to eq "Hello Jake"
264
264
  end
265
265
 
266
266
  it "creates objects that can be spied upon" do
@@ -268,8 +268,8 @@ describe Bogus::MockingDSL do
268
268
 
269
269
  greeter.greet("Jake")
270
270
 
271
- greeter.should have_received.greet("Jake")
272
- greeter.should_not have_received.greet("Bob")
271
+ expect(greeter).to have_received.greet("Jake")
272
+ expect(greeter).to_not have_received.greet("Bob")
273
273
  end
274
274
 
275
275
  it "verifies mock expectations set on anonymous fakes" do
@@ -307,15 +307,15 @@ describe Bogus::MockingDSL do
307
307
  it "returns configured fakes" do
308
308
  the_fake = Stubber.fake(:globally_configured_fake)
309
309
 
310
- the_fake.foo('a').should == "foo"
311
- the_fake.bar('a', 'b').should == "bar"
310
+ expect(the_fake.foo('a')).to eq "foo"
311
+ expect(the_fake.bar('a', 'b')).to eq "bar"
312
312
  end
313
313
 
314
314
  it "allows overwriting stubbed methods" do
315
315
  the_fake = Stubber.fake(:globally_configured_fake, bar: "baz")
316
316
 
317
- the_fake.foo('a').should == "foo"
318
- the_fake.bar('a', 'b').should == "baz"
317
+ expect(the_fake.foo('a')).to eq "foo"
318
+ expect(the_fake.bar('a', 'b')).to eq "baz"
319
319
  end
320
320
 
321
321
  it "evaluates the block passed to method in configuration when method is called" do
@@ -340,8 +340,8 @@ describe Bogus::MockingDSL do
340
340
  it "replaces the class for the duration of the test" do
341
341
  Stubber.fake_class(ThisClassWillBeReplaced, hello: "replaced!")
342
342
 
343
- ThisClassWillBeReplaced.hello("foo").should == "replaced!"
344
- ThisClassWillBeReplaced.should_not equal(TheOriginalClass)
343
+ expect(ThisClassWillBeReplaced.hello("foo")).to eq "replaced!"
344
+ expect(ThisClassWillBeReplaced).to_not equal(TheOriginalClass)
345
345
  end
346
346
 
347
347
  it "makes it possible to spy on classes" do
@@ -349,15 +349,15 @@ describe Bogus::MockingDSL do
349
349
 
350
350
  ThisClassWillBeReplaced.hello("foo")
351
351
 
352
- ThisClassWillBeReplaced.should Bogus.have_received.hello("foo")
353
- ThisClassWillBeReplaced.should_not Bogus.have_received.hello("bar")
352
+ expect(ThisClassWillBeReplaced).to Bogus.have_received.hello("foo")
353
+ expect(ThisClassWillBeReplaced).to_not Bogus.have_received.hello("bar")
354
354
  end
355
355
 
356
356
  it "restores the class after the test has finished" do
357
357
  Stubber.fake_class(ThisClassWillBeReplaced)
358
358
  Bogus.reset_overwritten_classes
359
359
 
360
- ThisClassWillBeReplaced.should equal(TheOriginalClass)
360
+ expect(ThisClassWillBeReplaced).to equal(TheOriginalClass)
361
361
  end
362
362
  end
363
363
 
@@ -385,7 +385,7 @@ describe Bogus::MockingDSL do
385
385
  end
386
386
 
387
387
  it "passes when all the mocked interactions were executed" do
388
- sample.greet("Welcome").should == "Welcome, John!"
388
+ expect(sample.greet("Welcome")).to eq "Welcome, John!"
389
389
 
390
390
  Bogus.after_each_test
391
391
 
@@ -395,7 +395,7 @@ describe Bogus::MockingDSL do
395
395
  end
396
396
 
397
397
  it "fails when contracts are fullfilled" do
398
- sample.greet("Hello").should == "Hello, John!"
398
+ expect(sample.greet("Hello")).to eq "Hello, John!"
399
399
 
400
400
  Bogus.after_each_test
401
401
 
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ if RUBY_VERSION >= '2.1'
4
+ describe "Ruby 2.1 required keyword arguments" do
5
+ class ExampleForRequiredKeywordArgs
6
+ eval "def foo(x:); end"
7
+ eval "def bar(x:, **rest); end"
8
+ end
9
+
10
+ include Bogus::MockingDSL
11
+
12
+ context "with regular objects" do
13
+ subject { ExampleForRequiredKeywordArgs.new }
14
+
15
+ it "does not allow calling the method without all required arguments" do
16
+ stub(subject).foo(any_args) { :hello }
17
+
18
+ expect{ subject.foo }.to raise_error(ArgumentError)
19
+ end
20
+
21
+ include_examples "stubbing methods with keyword arguments"
22
+ include_examples "stubbing methods with double splat"
23
+ end
24
+
25
+ context "with fakes" do
26
+ subject { fake(:example_for_required_keyword_args) }
27
+
28
+ it "allows spying without stubbing" do
29
+ subject.foo(x: "hello")
30
+
31
+ expect(subject).to have_received.foo(x: "hello")
32
+ end
33
+
34
+ include_examples "stubbing methods with keyword arguments"
35
+ include_examples "stubbing methods with double splat"
36
+ end
37
+ end
38
+ end
@@ -3,78 +3,22 @@ require 'spec_helper'
3
3
  if RUBY_VERSION >= '2.0'
4
4
  describe "Ruby 2.0 keyword arguments" do
5
5
  class ExampleForKeywordArgs
6
- eval "def foo(x: raise, y: 1); end"
6
+ eval "def foo(x: 1); end"
7
7
  eval "def bar(x: 1, **rest); end"
8
8
  end
9
9
 
10
10
  include Bogus::MockingDSL
11
11
 
12
- shared_examples_for "stubbing methods with keyword arguments" do
13
- it "can spy on stubbed methods" do
14
- stub(subject).foo(any_args)
15
-
16
- subject.foo(x: "test")
17
-
18
- subject.should have_received.foo(x: "test")
19
- subject.should_not have_received.foo(x: "baz")
20
- end
21
-
22
- it "can mock methods with keyword arguments" do
23
- mock(subject).foo(x: 1) { :return }
24
-
25
- subject.foo(x: 1).should == :return
26
-
27
- expect { Bogus.after_each_test }.not_to raise_error
28
- end
29
-
30
- it "can stub methods with keyword arguments" do
31
- stub(subject).foo(x: "bar") { :return_value }
32
-
33
- subject.foo(x: "bar").should == :return_value
34
- end
35
-
36
- it "raises on error on unknown keyword" do
37
- expect {
38
- stub(subject).foo(x: "bar", baz: "baz")
39
- }.to raise_error(ArgumentError)
40
- end
41
-
42
- it "does not overwrite the method signature" do
43
- stub(subject).foo(x: 1)
44
-
45
- expect {
46
- subject.foo(bar: 1)
47
- }.to raise_error(ArgumentError)
48
- end
49
- end
50
-
51
- shared_examples_for "stubbing methods with double splat" do
52
- it "can spy on stubbed methods" do
53
- stub(subject).bar(any_args)
54
-
55
- subject.bar(x: "test", z: "spec")
56
-
57
- subject.should have_received.bar(x: "test", z: "spec")
58
- subject.should_not have_received.bar(y: "baz")
59
- end
60
-
61
- it "can mock methods with keyword arguments" do
62
- mock(subject).bar(x: 1, z: 2) { :return }
63
-
64
- subject.bar(x: 1, z: 2).should == :return
12
+ context "with regular objects" do
13
+ subject { ExampleForKeywordArgs.new }
65
14
 
66
- expect { Bogus.after_each_test }.not_to raise_error
67
- end
15
+ it "allows calling the method without the optional keyword args" do
16
+ stub(subject).foo(any_args)
68
17
 
69
- it "can stub methods with keyword arguments" do
70
- stub(subject).bar(x: "bar", z: "bar") { :return_value }
18
+ subject.foo
71
19
 
72
- subject.bar(x: "bar", z: "bar").should == :return_value
20
+ expect(subject).to have_received.foo
73
21
  end
74
- end
75
-
76
- context "with regular objects" do
77
- subject { ExampleForKeywordArgs.new }
78
22
 
79
23
  include_examples "stubbing methods with keyword arguments"
80
24
  include_examples "stubbing methods with double splat"
@@ -86,7 +30,13 @@ if RUBY_VERSION >= '2.0'
86
30
  it "allows spying without stubbing" do
87
31
  subject.foo(x: "test")
88
32
 
89
- subject.should have_received.foo(x: "test")
33
+ expect(subject).to have_received.foo(x: "test")
34
+ end
35
+
36
+ it "allows calling the method without the optional keyword args" do
37
+ subject.foo
38
+
39
+ expect(subject).to have_received.foo
90
40
  end
91
41
 
92
42
  include_examples "stubbing methods with keyword arguments"