rspec-mocks 2.6.0 → 2.7.0

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 (69) hide show
  1. data/README.md +0 -19
  2. data/features/Scope.md +17 -0
  3. data/features/argument_matchers/README.md +27 -0
  4. data/features/argument_matchers/explicit.feature +60 -0
  5. data/features/argument_matchers/general_matchers.feature +85 -0
  6. data/features/argument_matchers/type_matchers.feature +25 -0
  7. data/features/message_expectations/any_instance.feature +2 -0
  8. data/features/message_expectations/receive_counts.feature +209 -0
  9. data/features/method_stubs/README.md +6 -10
  10. data/features/method_stubs/any_instance.feature +111 -1
  11. data/features/method_stubs/simple_return_value.feature +34 -25
  12. data/features/method_stubs/stub_implementation.feature +1 -1
  13. data/features/method_stubs/to_ary.feature +12 -10
  14. data/features/support/env.rb +1 -1
  15. data/lib/rspec/mocks/any_instance/chain.rb +49 -0
  16. data/lib/rspec/mocks/any_instance/expectation_chain.rb +33 -0
  17. data/lib/rspec/mocks/any_instance/message_chains.rb +48 -0
  18. data/lib/rspec/mocks/any_instance/recorder.rb +168 -0
  19. data/lib/rspec/mocks/any_instance/stub_chain.rb +35 -0
  20. data/lib/rspec/mocks/any_instance/stub_chain_chain.rb +34 -0
  21. data/lib/rspec/mocks/any_instance.rb +8 -235
  22. data/lib/rspec/mocks/argument_expectation.rb +1 -1
  23. data/lib/rspec/mocks/argument_matchers.rb +19 -25
  24. data/lib/rspec/mocks/extensions/marshal.rb +1 -1
  25. data/lib/rspec/mocks/extensions/psych.rb +1 -1
  26. data/lib/rspec/mocks/message_expectation.rb +7 -4
  27. data/lib/rspec/mocks/methods.rb +6 -8
  28. data/lib/rspec/mocks/mock.rb +2 -2
  29. data/lib/rspec/mocks/proxy.rb +4 -4
  30. data/lib/rspec/mocks/version.rb +4 -4
  31. data/lib/rspec/mocks.rb +13 -14
  32. data/spec/rspec/mocks/any_instance/message_chains_spec.rb +40 -0
  33. data/spec/rspec/mocks/any_instance_spec.rb +219 -24
  34. data/spec/rspec/mocks/any_number_of_times_spec.rb +2 -2
  35. data/spec/rspec/mocks/argument_expectation_spec.rb +15 -3
  36. data/spec/rspec/mocks/at_least_spec.rb +1 -1
  37. data/spec/rspec/mocks/at_most_spec.rb +1 -1
  38. data/spec/rspec/mocks/bug_report_10263_spec.rb +1 -1
  39. data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
  40. data/spec/rspec/mocks/bug_report_8165_spec.rb +2 -2
  41. data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
  42. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +1 -1
  43. data/spec/rspec/mocks/hash_including_matcher_spec.rb +11 -11
  44. data/spec/rspec/mocks/hash_not_including_matcher_spec.rb +6 -6
  45. data/spec/rspec/mocks/mock_spec.rb +49 -43
  46. data/spec/rspec/mocks/multiple_return_value_spec.rb +26 -26
  47. data/spec/rspec/mocks/partial_mock_spec.rb +3 -2
  48. data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -0
  49. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +3 -3
  50. data/spec/rspec/mocks/precise_counts_spec.rb +1 -1
  51. data/spec/rspec/mocks/serialization_spec.rb +7 -2
  52. data/spec/rspec/mocks/stub_implementation_spec.rb +6 -6
  53. data/spec/rspec/mocks/stub_spec.rb +6 -6
  54. data/spec/rspec/mocks/to_ary_spec.rb +9 -0
  55. metadata +45 -42
  56. data/.autotest +0 -7
  57. data/.document +0 -5
  58. data/.gitignore +0 -10
  59. data/.travis.yml +0 -7
  60. data/Gemfile +0 -40
  61. data/Guardfile +0 -8
  62. data/License.txt +0 -22
  63. data/Rakefile +0 -75
  64. data/autotest/discover.rb +0 -1
  65. data/cucumber.yml +0 -2
  66. data/features/.nav +0 -17
  67. data/features/Changelog.md +0 -80
  68. data/rspec-mocks.gemspec +0 -25
  69. data/specs.watchr +0 -57
@@ -8,7 +8,10 @@ module RSpec
8
8
  let(:klass) do
9
9
  Class.new do
10
10
  def existing_method; :existing_method_return_value; end
11
+ def existing_method_with_arguments(arg_one, arg_two = nil); :existing_method_with_arguments_return_value; end
11
12
  def another_existing_method; end
13
+ private
14
+ def private_method; :private_method_return_value; end
12
15
  end
13
16
  end
14
17
  let(:existing_method_return_value){ :existing_method_return_value }
@@ -31,7 +34,13 @@ module RSpec
31
34
  lambda{ klass.any_instance.stub(:foo).and_yield(1).with("1") }.should raise_error(NoMethodError)
32
35
  end
33
36
  end
34
-
37
+
38
+ context "#stub_chain" do
39
+ it "raises an error if 'stub_chain' follows 'any_instance'" do
40
+ lambda{ klass.any_instance.and_return("1").stub_chain(:foo, :bar) }.should raise_error(NoMethodError)
41
+ end
42
+ end
43
+
35
44
  context "#should_receive" do
36
45
  it "raises an error if 'should_receive' follows 'with'" do
37
46
  lambda{ klass.any_instance.with("1").should_receive(:foo) }.should raise_error(NoMethodError)
@@ -48,13 +57,44 @@ module RSpec
48
57
  end
49
58
  end
50
59
  end
51
-
60
+
52
61
  context "with #stub" do
53
62
  it "does not suppress an exception when a method that doesn't exist is invoked" do
54
63
  klass.any_instance.stub(:foo)
55
64
  lambda{ klass.new.bar }.should raise_error(NoMethodError)
56
65
  end
66
+
67
+ context 'multiple methods' do
68
+ it "allows multiple methods to be stubbed in a single invocation" do
69
+ klass.any_instance.stub(:foo => 'foo', :bar => 'bar')
70
+ instance = klass.new
71
+ instance.foo.should eq('foo')
72
+ instance.bar.should eq('bar')
73
+ end
74
+
75
+ it "adheres to the contract of multiple method stubbing withou any instance" do
76
+ Object.new.stub(:foo => 'foo', :bar => 'bar').should eq(:foo => 'foo', :bar => 'bar')
77
+ klass.any_instance.stub(:foo => 'foo', :bar => 'bar').should eq(:foo => 'foo', :bar => 'bar')
78
+ end
79
+
80
+ context "allows a chain of methods to be stubbed using #stub_chain" do
81
+ it "given symbols representing the methods" do
82
+ klass.any_instance.stub_chain(:one, :two, :three).and_return(:four)
83
+ klass.new.one.two.three.should eq(:four)
84
+ end
57
85
 
86
+ it "given a hash as the last argument uses the value as the expected return value" do
87
+ klass.any_instance.stub_chain(:one, :two, :three => :four)
88
+ klass.new.one.two.three.should eq(:four)
89
+ end
90
+
91
+ it "given a string of '.' separated method names representing the chain" do
92
+ klass.any_instance.stub_chain('one.two.three').and_return(:four)
93
+ klass.new.one.two.three.should eq(:four)
94
+ end
95
+ end
96
+ end
97
+
58
98
  context "behaves as 'every instance'" do
59
99
  it "stubs every instance in the spec" do
60
100
  klass.any_instance.stub(:foo).and_return(result = Object.new)
@@ -68,6 +108,43 @@ module RSpec
68
108
  instance.foo.should eq(result)
69
109
  end
70
110
  end
111
+
112
+ context "with argument matching" do
113
+ before do
114
+ klass.any_instance.stub(:foo).with(:param_one, :param_two).and_return(:result_one)
115
+ klass.any_instance.stub(:foo).with(:param_three, :param_four).and_return(:result_two)
116
+ end
117
+
118
+ it "returns the stubbed value when arguments match" do
119
+ instance = klass.new
120
+ instance.foo(:param_one, :param_two).should eq(:result_one)
121
+ instance.foo(:param_three, :param_four).should eq(:result_two)
122
+ end
123
+
124
+ it "fails the spec with an expectation error when the arguments do not match" do
125
+ expect do
126
+ klass.new.foo(:param_one, :param_three)
127
+ end.to(raise_error(RSpec::Mocks::MockExpectationError))
128
+ end
129
+ end
130
+
131
+ context "with multiple stubs" do
132
+ before do
133
+ klass.any_instance.stub(:foo).and_return(1)
134
+ klass.any_instance.stub(:bar).and_return(2)
135
+ end
136
+
137
+ it "stubs a method" do
138
+ instance = klass.new
139
+ instance.foo.should eq(1)
140
+ instance.bar.should eq(2)
141
+ end
142
+
143
+ it "returns the same value for calls on different instances" do
144
+ klass.new.foo.should eq(klass.new.foo)
145
+ klass.new.bar.should eq(klass.new.bar)
146
+ end
147
+ end
71
148
 
72
149
  context "with #and_return" do
73
150
  it "stubs a method that doesn't exist" do
@@ -119,7 +196,7 @@ module RSpec
119
196
  klass.new.foo.should eq(klass.new.foo)
120
197
  end
121
198
  end
122
-
199
+
123
200
  context "core ruby objects" do
124
201
  it "works uniformly across *everything*" do
125
202
  Object.any_instance.stub(:foo).and_return(1)
@@ -160,6 +237,42 @@ module RSpec
160
237
  end
161
238
  end
162
239
 
240
+ context "with #stub!" do
241
+ it "raises with a message instructing the user to use stub instead" do
242
+ expect do
243
+ klass.any_instance.stub!(:foo)
244
+ end.to raise_error(/Use stub instead/)
245
+ end
246
+ end
247
+
248
+ context "unstub implementation" do
249
+ it "replaces the stubbed method with the original method" do
250
+ klass.any_instance.stub(:existing_method)
251
+ klass.any_instance.unstub(:existing_method)
252
+ klass.new.existing_method.should eq(:existing_method_return_value)
253
+ end
254
+
255
+ it "removes all stubs with the supplied method name" do
256
+ klass.any_instance.stub(:existing_method).with(1)
257
+ klass.any_instance.stub(:existing_method).with(2)
258
+ klass.any_instance.unstub(:existing_method)
259
+ klass.new.existing_method.should eq(:existing_method_return_value)
260
+ end
261
+
262
+ it "does not remove any expectations with the same method name" do
263
+ klass.any_instance.should_receive(:existing_method_with_arguments).with(3).and_return(:three)
264
+ klass.any_instance.stub(:existing_method_with_arguments).with(1)
265
+ klass.any_instance.stub(:existing_method_with_arguments).with(2)
266
+ klass.any_instance.unstub(:existing_method_with_arguments)
267
+ klass.new.existing_method_with_arguments(3).should eq :three
268
+ end
269
+
270
+ it "raises a MockExpectationError if the method has not been stubbed" do
271
+ lambda do
272
+ klass.any_instance.unstub(:existing_method)
273
+ end.should raise_error(RSpec::Mocks::MockExpectationError, 'The method `existing_method` was not stubbed or was already unstubbed')
274
+ end
275
+ end
163
276
  context "with #should_receive" do
164
277
  let(:foo_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: foo' }
165
278
  let(:existing_method_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: existing_method' }
@@ -292,6 +405,47 @@ module RSpec
292
405
  end
293
406
  end
294
407
 
408
+ context "with argument matching" do
409
+ before do
410
+ klass.any_instance.should_receive(:foo).with(:param_one, :param_two).and_return(:result_one)
411
+ klass.any_instance.should_receive(:foo).with(:param_three, :param_four).and_return(:result_two)
412
+ end
413
+
414
+ it "returns the expected value when arguments match" do
415
+ instance = klass.new
416
+ instance.foo(:param_one, :param_two).should eq(:result_one)
417
+ instance.foo(:param_three, :param_four).should eq(:result_two)
418
+ end
419
+
420
+ it "fails when the arguments match but different instances are used" do
421
+ instances = Array.new(2) { klass.new }
422
+ expect do
423
+ instances[0].foo(:param_one, :param_two).should eq(:result_one)
424
+ instances[1].foo(:param_three, :param_four).should eq(:result_two)
425
+ end.to raise_error(RSpec::Mocks::MockExpectationError)
426
+
427
+ # ignore the fact that should_receive expectations were not met
428
+ instances.each { |instance| instance.rspec_reset }
429
+ end
430
+
431
+ it "is not affected by the invocation of existing methods on other instances" do
432
+ klass.new.existing_method_with_arguments(:param_one, :param_two).should eq(:existing_method_with_arguments_return_value)
433
+ instance = klass.new
434
+ instance.foo(:param_one, :param_two).should eq(:result_one)
435
+ instance.foo(:param_three, :param_four).should eq(:result_two)
436
+ end
437
+
438
+ it "fails when arguments do not match" do
439
+ instance = klass.new
440
+ expect do
441
+ instance.foo(:param_one, :param_three)
442
+ end.to raise_error(RSpec::Mocks::MockExpectationError)
443
+
444
+ # ignore the fact that should_receive expectations were not met
445
+ instance.rspec_reset
446
+ end
447
+ end
448
+
295
449
  context "message count" do
296
450
  context "the 'once' constraint" do
297
451
  it "passes for one invocation" do
@@ -490,39 +644,80 @@ module RSpec
490
644
  end
491
645
 
492
646
  context "with stubbing" do
493
- before(:each) do
494
- klass.any_instance.stub(:existing_method).and_return(1)
495
- klass.method_defined?(:__existing_method_without_any_instance__).should be_true
496
- end
647
+ context "public methods" do
648
+ before(:each) do
649
+ klass.any_instance.stub(:existing_method).and_return(1)
650
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_true
651
+ end
497
652
 
498
- it "restores the class to its original state after each example when no instance is created" do
499
- space.verify_all
653
+ it "restores the class to its original state after each example when no instance is created" do
654
+ space.verify_all
500
655
 
501
- klass.method_defined?(:__existing_method_without_any_instance__).should be_false
502
- klass.new.existing_method.should eq(existing_method_return_value)
503
- end
656
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_false
657
+ klass.new.existing_method.should eq(existing_method_return_value)
658
+ end
504
659
 
505
- it "restores the class to its original state after each example when one instance is created" do
506
- klass.new.existing_method
660
+ it "restores the class to its original state after each example when one instance is created" do
661
+ klass.new.existing_method
507
662
 
508
- space.verify_all
663
+ space.verify_all
509
664
 
510
- klass.method_defined?(:__existing_method_without_any_instance__).should be_false
511
- klass.new.existing_method.should eq(existing_method_return_value)
512
- end
665
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_false
666
+ klass.new.existing_method.should eq(existing_method_return_value)
667
+ end
513
668
 
514
- it "restores the class to its original state after each example when more than one instance is created" do
515
- klass.new.existing_method
516
- klass.new.existing_method
669
+ it "restores the class to its original state after each example when more than one instance is created" do
670
+ klass.new.existing_method
671
+ klass.new.existing_method
517
672
 
518
- space.verify_all
673
+ space.verify_all
519
674
 
520
- klass.method_defined?(:__existing_method_without_any_instance__).should be_false
521
- klass.new.existing_method.should eq(existing_method_return_value)
675
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_false
676
+ klass.new.existing_method.should eq(existing_method_return_value)
677
+ end
678
+ end
679
+
680
+ context "private methods" do
681
+ before :each do
682
+ klass.any_instance.stub(:private_method).and_return(:something)
683
+ space.verify_all
684
+ end
685
+
686
+ it "cleans up the backed up method" do
687
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_false
688
+ end
689
+
690
+ it "restores a stubbed private method after the spec is run" do
691
+ klass.private_method_defined?(:private_method).should be_true
692
+ end
693
+
694
+ it "ensures that the restored method behaves as it originally did" do
695
+ klass.new.send(:private_method).should eq(:private_method_return_value)
696
+ end
522
697
  end
523
698
  end
524
699
 
525
700
  context "with expectations" do
701
+ context "private methods" do
702
+ before :each do
703
+ klass.any_instance.should_receive(:private_method).and_return(:something)
704
+ klass.new.private_method
705
+ space.verify_all
706
+ end
707
+
708
+ it "cleans up the backed up method" do
709
+ klass.method_defined?(:__existing_method_without_any_instance__).should be_false
710
+ end
711
+
712
+ it "restores a stubbed private method after the spec is run" do
713
+ klass.private_method_defined?(:private_method).should be_true
714
+ end
715
+
716
+ it "ensures that the restored method behaves as it originally did" do
717
+ klass.new.send(:private_method).should eq(:private_method_return_value)
718
+ end
719
+ end
720
+
526
721
  context "ensures that the subsequent specs do not see expectations set in previous specs" do
527
722
  context "when the instance created after the expectation is set" do
528
723
  it "first spec" do
@@ -24,7 +24,7 @@ describe "AnyNumberOfTimes" do
24
24
  it "returns the mocked value when called after a similar stub" do
25
25
  @mock.stub(:message).and_return :stub_value
26
26
  @mock.should_receive(:message).any_number_of_times.and_return(:mock_value)
27
- @mock.message.should == :mock_value
28
- @mock.message.should == :mock_value
27
+ @mock.message.should eq :mock_value
28
+ @mock.message.should eq :mock_value
29
29
  end
30
30
  end
@@ -3,12 +3,23 @@ require 'spec_helper'
3
3
  module RSpec
4
4
  module Mocks
5
5
  describe ArgumentExpectation do
6
- it "considers an object that responds to #matches? and #description to be a matcher" do
6
+
7
+ it "considers an object that responds to #matches? and #failure_message_for_should to be a matcher" do
7
8
  argument_expecatation = RSpec::Mocks::ArgumentExpectation.new
8
9
  obj = double("matcher")
9
10
  obj.stub(:respond_to?).with(:__rspec_double_acting_as_null_object?).and_return(false)
10
11
  obj.stub(:respond_to?).with(:matches?).and_return(true)
11
- obj.stub(:respond_to?).with(:description).and_return(true)
12
+ obj.stub(:respond_to?).with(:failure_message_for_should).and_return(true)
13
+ argument_expecatation.is_matcher?(obj).should be_true
14
+ end
15
+
16
+ it "considers an object that responds to #matches? and #failure_message to be a matcher for backward compatibility" do
17
+ argument_expecatation = RSpec::Mocks::ArgumentExpectation.new
18
+ obj = double("matcher")
19
+ obj.stub(:respond_to?).with(:__rspec_double_acting_as_null_object?).and_return(false)
20
+ obj.stub(:respond_to?).with(:matches?).and_return(true)
21
+ obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
22
+ obj.stub(:respond_to?).with(:failure_message).and_return(true)
12
23
  argument_expecatation.is_matcher?(obj).should be_true
13
24
  end
14
25
 
@@ -17,7 +28,8 @@ module RSpec
17
28
  obj = double("matcher")
18
29
  obj.stub(:respond_to?).with(:__rspec_double_acting_as_null_object?).and_return(false)
19
30
  obj.stub(:respond_to?).with(:matches?).and_return(true)
20
- obj.stub(:respond_to?).with(:description).and_return(false)
31
+ obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
32
+ obj.stub(:respond_to?).with(:failure_message).and_return(false)
21
33
  argument_expecatation.is_matcher?(obj).should be_false
22
34
  end
23
35
  end
@@ -95,7 +95,7 @@ module RSpec
95
95
 
96
96
  it "returns the value given by a block when the at least once method is called" do
97
97
  @mock.should_receive(:to_s).at_least(:once) { "testing" }
98
- @mock.to_s.should == "testing"
98
+ @mock.to_s.should eq "testing"
99
99
  @mock.rspec_verify
100
100
  end
101
101
  end
@@ -91,7 +91,7 @@ module RSpec
91
91
 
92
92
  it "returns the value given by a block when the at most once method is called" do
93
93
  @mock.should_receive(:to_s).at_most(:once) { "testing" }
94
- @mock.to_s.should == "testing"
94
+ @mock.to_s.should eq "testing"
95
95
  @mock.rspec_verify
96
96
  end
97
97
  end
@@ -18,7 +18,7 @@ describe "Double" do
18
18
  begin
19
19
  test_double.foobar
20
20
  rescue Exception => e
21
- e.message.should == "Double received unexpected message :foobar with (no args)"
21
+ e.message.should eq "Double received unexpected message :foobar with (no args)"
22
22
  end
23
23
  end
24
24
  end
@@ -10,7 +10,7 @@ module Bug7611
10
10
  end
11
11
 
12
12
  it "should" do
13
- Bar.new.class.should == Bar
13
+ Bar.new.class.should eq Bar
14
14
  end
15
15
  end
16
16
  end
@@ -17,7 +17,7 @@ describe "An object where respond_to? is true and does not have method" do
17
17
  obj.should_receive(:respond_to?).with(:foobar).and_return(true)
18
18
  obj.should_receive(:foobar).and_return(:baz)
19
19
  obj.respond_to?(:foobar).should be_true
20
- obj.foobar.should == :baz
20
+ obj.foobar.should eq :baz
21
21
  end
22
22
 
23
23
  it "does not raise an exception for mock" do
@@ -25,7 +25,7 @@ describe "An object where respond_to? is true and does not have method" do
25
25
  obj.should_receive(:respond_to?).with(:foobar).and_return(true)
26
26
  obj.should_receive(:foobar).and_return(:baz)
27
27
  obj.respond_to?(:foobar).should be_true
28
- obj.foobar.should == :baz
28
+ obj.foobar.should eq :baz
29
29
  end
30
30
 
31
31
  end
@@ -11,11 +11,11 @@ module RSpec
11
11
  end
12
12
 
13
13
  it "returns the value for the stub on the base class" do
14
- @base_class.find.should == "stubbed_value"
14
+ @base_class.find.should eq "stubbed_value"
15
15
  end
16
16
 
17
17
  it "returns the value for the descendent class" do
18
- @concrete_class.find.should == "stubbed_value"
18
+ @concrete_class.find.should eq "stubbed_value"
19
19
  end
20
20
  end
21
21
  end
@@ -85,7 +85,7 @@ module RSpec
85
85
 
86
86
  it "fails with block matchers" do
87
87
  expect do
88
- @double.should_receive(:msg).with {|arg| arg.should == :received }
88
+ @double.should_receive(:msg).with {|arg| arg.should eq :received }
89
89
  @double.msg :no_msg_for_you
90
90
  end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected: :received.*\s*.*got: :no_msg_for_you/)
91
91
  end
@@ -6,51 +6,51 @@ module RSpec
6
6
  describe HashIncludingMatcher do
7
7
 
8
8
  it "describes itself properly" do
9
- HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)"
9
+ HashIncludingMatcher.new(:a => 1).description.should eq "hash_including(:a=>1)"
10
10
  end
11
11
 
12
12
  describe "passing" do
13
13
  it "matches the same hash" do
14
- hash_including(:a => 1).should == {:a => 1}
14
+ hash_including(:a => 1).should eq({:a => 1})
15
15
  end
16
16
 
17
17
  it "matches a hash with extra stuff" do
18
- hash_including(:a => 1).should == {:a => 1, :b => 2}
18
+ hash_including(:a => 1).should eq({:a => 1, :b => 2})
19
19
  end
20
20
 
21
21
  describe "when matching against other matchers" do
22
22
  it "matches an int against anything()" do
23
- hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2}
23
+ hash_including(:a => anything, :b => 2).should eq({:a => 1, :b => 2})
24
24
  end
25
25
 
26
26
  it "matches a string against anything()" do
27
- hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2}
27
+ hash_including(:a => anything, :b => 2).should eq({:a => "1", :b => 2})
28
28
  end
29
29
  end
30
30
 
31
31
  describe "when passed only keys or keys mixed with key/value pairs" do
32
32
  it "matches if the key is present" do
33
- hash_including(:a).should == {:a => 1, :b => 2}
33
+ hash_including(:a).should eq({:a => 1, :b => 2})
34
34
  end
35
35
 
36
36
  it "matches if more keys are present" do
37
- hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3}
37
+ hash_including(:a, :b).should eq({:a => 1, :b => 2, :c => 3})
38
38
  end
39
39
 
40
40
  it "matches a string against a given key" do
41
- hash_including(:a).should == {:a => "1", :b => 2}
41
+ hash_including(:a).should eq({:a => "1", :b => 2})
42
42
  end
43
43
 
44
44
  it "matches if passed one key and one key/value pair" do
45
- hash_including(:a, :b => 2).should == {:a => 1, :b => 2}
45
+ hash_including(:a, :b => 2).should eq({:a => 1, :b => 2})
46
46
  end
47
47
 
48
48
  it "matches if passed many keys and one key/value pair" do
49
- hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4}
49
+ hash_including(:a, :b, :c => 3).should eq({:a => 1, :b => 2, :c => 3, :d => 4})
50
50
  end
51
51
 
52
52
  it "matches if passed many keys and many key/value pairs" do
53
- hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}
53
+ hash_including(:a, :b, :c => 3, :e => 5).should eq({:a => 1, :b => 2, :c => 3, :d => 4, :e => 5})
54
54
  end
55
55
  end
56
56
  end
@@ -6,28 +6,28 @@ module RSpec
6
6
  describe HashNotIncludingMatcher do
7
7
 
8
8
  it "describes itself properly" do
9
- HashNotIncludingMatcher.new(:a => 5).description.should == "hash_not_including(:a=>5)"
9
+ HashNotIncludingMatcher.new(:a => 5).description.should eq "hash_not_including(:a=>5)"
10
10
  end
11
11
 
12
12
  describe "passing" do
13
13
  it "matches a hash without the specified key" do
14
- hash_not_including(:c).should == {:a => 1, :b => 2}
14
+ hash_not_including(:c).should eq({:a => 1, :b => 2})
15
15
  end
16
16
 
17
17
  it "matches a hash with the specified key, but different value" do
18
- hash_not_including(:b => 3).should == {:a => 1, :b => 2}
18
+ hash_not_including(:b => 3).should eq({:a => 1, :b => 2})
19
19
  end
20
20
 
21
21
  it "matches a hash without the specified key, given as anything()" do
22
- hash_not_including(:c => anything).should == {:a => 1, :b => 2}
22
+ hash_not_including(:c => anything).should eq({:a => 1, :b => 2})
23
23
  end
24
24
 
25
25
  it "matches an empty hash" do
26
- hash_not_including(:a).should == {}
26
+ hash_not_including(:a).should eq({})
27
27
  end
28
28
 
29
29
  it "matches a hash without any of the specified keys" do
30
- hash_not_including(:a, :b, :c).should == { :d => 7}
30
+ hash_not_including(:a, :b, :c).should eq({ :d => 7})
31
31
  end
32
32
 
33
33
  end