rspec-mocks 2.12.1 → 2.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/Changelog.md +17 -0
  2. data/lib/rspec/mocks.rb +8 -0
  3. data/lib/rspec/mocks/message_expectation.rb +6 -11
  4. data/lib/rspec/mocks/method_double.rb +19 -2
  5. data/lib/rspec/mocks/mutate_const.rb +1 -1
  6. data/lib/rspec/mocks/proxy.rb +1 -1
  7. data/lib/rspec/mocks/version.rb +1 -1
  8. data/lib/spec/mocks.rb +4 -0
  9. data/spec/rspec/mocks/and_call_original_spec.rb +22 -0
  10. data/spec/rspec/mocks/and_yield_spec.rb +7 -7
  11. data/spec/rspec/mocks/any_instance/message_chains_spec.rb +6 -6
  12. data/spec/rspec/mocks/any_instance_spec.rb +94 -94
  13. data/spec/rspec/mocks/any_number_of_times_spec.rb +2 -2
  14. data/spec/rspec/mocks/argument_expectation_spec.rb +3 -3
  15. data/spec/rspec/mocks/at_least_spec.rb +15 -15
  16. data/spec/rspec/mocks/at_most_spec.rb +7 -7
  17. data/spec/rspec/mocks/block_return_value_spec.rb +6 -6
  18. data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
  19. data/spec/rspec/mocks/bug_report_10263_spec.rb +6 -4
  20. data/spec/rspec/mocks/bug_report_11545_spec.rb +1 -1
  21. data/spec/rspec/mocks/bug_report_600_spec.rb +1 -1
  22. data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
  23. data/spec/rspec/mocks/bug_report_8165_spec.rb +4 -4
  24. data/spec/rspec/mocks/bug_report_830_spec.rb +2 -2
  25. data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
  26. data/spec/rspec/mocks/configuration_spec.rb +4 -4
  27. data/spec/rspec/mocks/double_spec.rb +1 -1
  28. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +1 -1
  29. data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +13 -13
  30. data/spec/rspec/mocks/hash_including_matcher_spec.rb +30 -30
  31. data/spec/rspec/mocks/mock_ordering_spec.rb +8 -8
  32. data/spec/rspec/mocks/mock_space_spec.rb +4 -4
  33. data/spec/rspec/mocks/mock_spec.rb +94 -90
  34. data/spec/rspec/mocks/multiple_return_value_spec.rb +21 -21
  35. data/spec/rspec/mocks/mutate_const_spec.rb +112 -102
  36. data/spec/rspec/mocks/nil_expectation_warning_spec.rb +6 -12
  37. data/spec/rspec/mocks/null_object_mock_spec.rb +12 -12
  38. data/spec/rspec/mocks/once_counts_spec.rb +7 -7
  39. data/spec/rspec/mocks/options_hash_spec.rb +6 -6
  40. data/spec/rspec/mocks/partial_mock_spec.rb +15 -15
  41. data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +17 -17
  42. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +6 -6
  43. data/spec/rspec/mocks/precise_counts_spec.rb +7 -7
  44. data/spec/rspec/mocks/record_messages_spec.rb +4 -4
  45. data/spec/rspec/mocks/serialization_spec.rb +3 -3
  46. data/spec/rspec/mocks/stash_spec.rb +1 -1
  47. data/spec/rspec/mocks/stub_chain_spec.rb +22 -22
  48. data/spec/rspec/mocks/stub_implementation_spec.rb +10 -10
  49. data/spec/rspec/mocks/stub_spec.rb +50 -31
  50. data/spec/rspec/mocks/stubbed_message_expectations_spec.rb +3 -3
  51. data/spec/rspec/mocks/test_double_spec.rb +3 -3
  52. data/spec/rspec/mocks/to_ary_spec.rb +7 -7
  53. data/spec/rspec/mocks/twice_counts_spec.rb +8 -8
  54. data/spec/rspec/mocks_spec.rb +13 -4
  55. data/spec/spec_helper.rb +4 -0
  56. metadata +5 -5
@@ -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 eq :mock_value
28
- @mock.message.should eq :mock_value
27
+ expect(@mock.message).to eq :mock_value
28
+ expect(@mock.message).to eq :mock_value
29
29
  end
30
30
  end
@@ -9,7 +9,7 @@ module RSpec
9
9
  obj = double("matcher")
10
10
  obj.stub(:respond_to?).with(:matches?).and_return(true)
11
11
  obj.stub(:respond_to?).with(:failure_message_for_should).and_return(true)
12
- argument_expectation.send(:is_matcher?, obj).should be_true
12
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_true
13
13
  end
14
14
 
15
15
  it "considers an object that responds to #matches? and #failure_message to be a matcher for backward compatibility" do
@@ -18,7 +18,7 @@ module RSpec
18
18
  obj.stub(:respond_to?).with(:matches?).and_return(true)
19
19
  obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
20
20
  obj.stub(:respond_to?).with(:failure_message).and_return(true)
21
- argument_expectation.send(:is_matcher?, obj).should be_true
21
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_true
22
22
  end
23
23
 
24
24
  it "does NOT consider an object that only responds to #matches? to be a matcher" do
@@ -27,7 +27,7 @@ module RSpec
27
27
  obj.stub(:respond_to?).with(:matches?).and_return(true)
28
28
  obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
29
29
  obj.stub(:respond_to?).with(:failure_message).and_return(false)
30
- argument_expectation.send(:is_matcher?, obj).should be_false
30
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_false
31
31
  end
32
32
  end
33
33
  end
@@ -7,9 +7,9 @@ module RSpec
7
7
 
8
8
  it "fails if method is never called" do
9
9
  @double.should_receive(:do_something).at_least(4).times
10
- lambda do
10
+ expect {
11
11
  @double.rspec_verify
12
- end.should raise_error(RSpec::Mocks::MockExpectationError)
12
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
13
13
  end
14
14
 
15
15
  it "fails when called less than n times" do
@@ -17,31 +17,31 @@ module RSpec
17
17
  @double.do_something
18
18
  @double.do_something
19
19
  @double.do_something
20
- lambda do
20
+ expect {
21
21
  @double.rspec_verify
22
- end.should raise_error(RSpec::Mocks::MockExpectationError)
22
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
23
23
  end
24
24
 
25
25
  it "fails when at least once method is never called" do
26
26
  @double.should_receive(:do_something).at_least(:once)
27
- lambda do
27
+ expect {
28
28
  @double.rspec_verify
29
- end.should raise_error(RSpec::Mocks::MockExpectationError)
29
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
30
30
  end
31
31
 
32
32
  it "fails when at least twice method is called once" do
33
33
  @double.should_receive(:do_something).at_least(:twice)
34
34
  @double.do_something
35
- lambda do
35
+ expect {
36
36
  @double.rspec_verify
37
- end.should raise_error(RSpec::Mocks::MockExpectationError)
37
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
38
38
  end
39
39
 
40
40
  it "fails when at least twice method is never called" do
41
41
  @double.should_receive(:do_something).at_least(:twice)
42
- lambda do
42
+ expect {
43
43
  @double.rspec_verify
44
- end.should raise_error(RSpec::Mocks::MockExpectationError)
44
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
45
45
  end
46
46
 
47
47
  it "passes when at least n times method is called exactly n times" do
@@ -93,7 +93,7 @@ module RSpec
93
93
 
94
94
  it "returns the value given by a block when the at least once method is called" do
95
95
  @double.should_receive(:to_s).at_least(:once) { "testing" }
96
- @double.to_s.should eq "testing"
96
+ expect(@double.to_s).to eq "testing"
97
97
  @double.rspec_verify
98
98
  end
99
99
 
@@ -127,15 +127,15 @@ module RSpec
127
127
  it "uses a stub value if no value set" do
128
128
  @double.stub(:do_something => 'foo')
129
129
  @double.should_receive(:do_something).at_least(:once)
130
- @double.do_something.should eq 'foo'
131
- @double.do_something.should eq 'foo'
130
+ expect(@double.do_something).to eq 'foo'
131
+ expect(@double.do_something).to eq 'foo'
132
132
  end
133
133
 
134
134
  it "prefers its own return value over a stub" do
135
135
  @double.stub(:do_something => 'foo')
136
136
  @double.should_receive(:do_something).at_least(:once).and_return('bar')
137
- @double.do_something.should eq 'bar'
138
- @double.do_something.should eq 'bar'
137
+ expect(@double.do_something).to eq 'bar'
138
+ expect(@double.do_something).to eq 'bar'
139
139
  end
140
140
  end
141
141
  end
@@ -56,7 +56,7 @@ module RSpec
56
56
 
57
57
  it "returns the value given by a block when at_most(:once) method is called" do
58
58
  @double.should_receive(:to_s).at_most(:once) { "testing" }
59
- @double.to_s.should eq "testing"
59
+ expect(@double.to_s).to eq "testing"
60
60
  @double.rspec_verify
61
61
  end
62
62
 
@@ -64,26 +64,26 @@ module RSpec
64
64
  @double.should_receive(:do_something).at_most(2).times
65
65
  @double.do_something
66
66
  @double.do_something
67
- lambda do
67
+ expect {
68
68
  @double.do_something
69
- end.should raise_error(RSpec::Mocks::MockExpectationError)
69
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
70
70
  end
71
71
 
72
72
  it "fails fast when at_most(:once) and is called twice" do
73
73
  @double.should_receive(:do_something).at_most(:once)
74
74
  @double.do_something
75
- lambda do
75
+ expect {
76
76
  @double.do_something
77
- end.should raise_error(RSpec::Mocks::MockExpectationError)
77
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
78
78
  end
79
79
 
80
80
  it "fails fast when at_most(:twice) and is called three times" do
81
81
  @double.should_receive(:do_something).at_most(:twice)
82
82
  @double.do_something
83
83
  @double.do_something
84
- lambda do
84
+ expect {
85
85
  @double.do_something
86
- end.should raise_error(RSpec::Mocks::MockExpectationError)
86
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
87
87
  end
88
88
  end
89
89
  end
@@ -5,7 +5,7 @@ describe "a double declaration with a block handed to:" do
5
5
  it "returns the value of executing the block" do
6
6
  obj = Object.new
7
7
  obj.should_receive(:foo) { 'bar' }
8
- obj.foo.should eq('bar')
8
+ expect(obj.foo).to eq('bar')
9
9
  end
10
10
 
11
11
  it "works when a multi-return stub has already been set" do
@@ -13,7 +13,7 @@ describe "a double declaration with a block handed to:" do
13
13
  return_value = Object.new
14
14
  obj.stub(:foo).and_return(return_value, nil)
15
15
  obj.should_receive(:foo) { return_value }
16
- obj.foo.should be(return_value)
16
+ expect(obj.foo).to be(return_value)
17
17
  end
18
18
  end
19
19
 
@@ -21,7 +21,7 @@ describe "a double declaration with a block handed to:" do
21
21
  it "returns the value of executing the block" do
22
22
  obj = Object.new
23
23
  obj.stub(:foo) { 'bar' }
24
- obj.foo.should eq('bar')
24
+ expect(obj.foo).to eq('bar')
25
25
  end
26
26
  end
27
27
 
@@ -29,7 +29,7 @@ describe "a double declaration with a block handed to:" do
29
29
  it "returns the value of executing the block" do
30
30
  obj = Object.new
31
31
  obj.stub(:foo).with('baz') { 'bar' }
32
- obj.foo('baz').should eq('bar')
32
+ expect(obj.foo('baz')).to eq('bar')
33
33
  end
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ describe "a double declaration with a block handed to:" do
38
38
  it "returns the value of executing the block" do
39
39
  obj = Object.new
40
40
  obj.stub(:foo).send(method) { 'bar' }
41
- obj.foo.should eq('bar')
41
+ expect(obj.foo).to eq('bar')
42
42
  end
43
43
  end
44
44
  end
@@ -47,7 +47,7 @@ describe "a double declaration with a block handed to:" do
47
47
  it "returns the value of executing the block" do
48
48
  obj = Object.new
49
49
  obj.stub(:foo).at_least(1).times { 'bar' }
50
- obj.foo('baz').should eq('bar')
50
+ expect(obj.foo('baz')).to eq('bar')
51
51
  end
52
52
  end
53
53
  end
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
  describe "An RSpec Mock" do
4
4
  it "hides internals in its inspect representation" do
5
5
  m = double('cup')
6
- m.inspect.should =~ /#<RSpec::Mocks::Mock:0x[a-f0-9.]+ @name="cup">/
6
+ expect(m.inspect).to match /#<RSpec::Mocks::Mock:0x[a-f0-9.]+ @name="cup">/
7
7
  end
8
8
  end
@@ -1,16 +1,18 @@
1
+ require 'spec_helper'
2
+
1
3
  describe "Double" do
2
4
  let(:test_double) { double }
3
5
 
4
6
  specify "when one example has an expectation inside the block passed to should_receive" do
5
7
  test_double.should_receive(:msg) do |arg|
6
- arg.should be_true #this call exposes the problem
8
+ expect(arg).to be_true #this call exposes the problem
7
9
  end
8
10
  begin
9
11
  test_double.msg(false)
10
12
  rescue Exception
11
13
  end
12
14
  end
13
-
15
+
14
16
  specify "then the next example should behave as expected instead of saying" do
15
17
  test_double.should_receive(:foobar)
16
18
  test_double.foobar
@@ -18,8 +20,8 @@ describe "Double" do
18
20
  begin
19
21
  test_double.foobar
20
22
  rescue Exception => e
21
- e.message.should eq "Double received unexpected message :foobar with (no args)"
23
+ expect(e.message).to eq "Double received unexpected message :foobar with (no args)"
22
24
  end
23
- end
25
+ end
24
26
  end
25
27
 
@@ -26,7 +26,7 @@ describe 'should_receive' do
26
26
  end
27
27
 
28
28
  it 'cleans up after itself' do
29
- (class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something")
29
+ expect((class << LiarLiarPantsOnFire; self; end).instance_methods).not_to include("something")
30
30
  end
31
31
  end
32
32
 
@@ -19,4 +19,4 @@ module BugReport600
19
19
  ExampleClass.method_that_uses_define_method
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -10,7 +10,7 @@ module Bug7611
10
10
  end
11
11
 
12
12
  it "should" do
13
- Bar.new.class.should eq Bar
13
+ expect(Bar.new.class).to eq Bar
14
14
  end
15
15
  end
16
16
  end
@@ -16,16 +16,16 @@ describe "An object where respond_to? is true and does not have method" do
16
16
  obj = Object.new
17
17
  obj.should_receive(:respond_to?).with(:foobar).and_return(true)
18
18
  obj.should_receive(:foobar).and_return(:baz)
19
- obj.respond_to?(:foobar).should be_true
20
- obj.foobar.should eq :baz
19
+ expect(obj.respond_to?(:foobar)).to be_true
20
+ expect(obj.foobar).to eq :baz
21
21
  end
22
22
 
23
23
  it "does not raise an exception for mock" do
24
24
  obj = double("obj")
25
25
  obj.should_receive(:respond_to?).with(:foobar).and_return(true)
26
26
  obj.should_receive(:foobar).and_return(:baz)
27
- obj.respond_to?(:foobar).should be_true
28
- obj.foobar.should eq :baz
27
+ expect(obj.respond_to?(:foobar)).to be_true
28
+ expect(obj.foobar).to eq :baz
29
29
  end
30
30
 
31
31
  end
@@ -12,9 +12,9 @@ module RSpec
12
12
 
13
13
  it 'still reports mock failures' do
14
14
  Foo.should_not_receive :bar
15
- lambda do
15
+ expect {
16
16
  Foo.foo
17
- end.should raise_error(RSpec::Mocks::MockExpectationError)
17
+ }.to raise_error(RSpec::Mocks::MockExpectationError)
18
18
  end
19
19
  end
20
20
  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 eq "stubbed_value"
14
+ expect(@base_class.find).to eq "stubbed_value"
15
15
  end
16
16
 
17
17
  it "returns the value for the descendent class" do
18
- @concrete_class.find.should eq "stubbed_value"
18
+ expect(@concrete_class.find).to eq "stubbed_value"
19
19
  end
20
20
  end
21
21
  end
@@ -12,13 +12,13 @@ module RSpec
12
12
  end
13
13
 
14
14
  it 'adds stub and should_receive to the given modules' do
15
- instance_methods_of(mod_1).should_not include(:stub, :should_receive)
16
- instance_methods_of(mod_2).should_not include(:stub, :should_receive)
15
+ expect(instance_methods_of(mod_1)).not_to include(:stub, :should_receive)
16
+ expect(instance_methods_of(mod_2)).not_to include(:stub, :should_receive)
17
17
 
18
18
  config.add_stub_and_should_receive_to(mod_1, mod_2)
19
19
 
20
- instance_methods_of(mod_1).should include(:stub, :should_receive)
21
- instance_methods_of(mod_2).should include(:stub, :should_receive)
20
+ expect(instance_methods_of(mod_1)).to include(:stub, :should_receive)
21
+ expect(instance_methods_of(mod_2)).to include(:stub, :should_receive)
22
22
  end
23
23
  end
24
24
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe "double" do
4
4
  it "is an alias for stub and mock" do
5
- double().should be_a(RSpec::Mocks::Mock)
5
+ expect(double()).to be_a(RSpec::Mocks::Mock)
6
6
  end
7
7
 
8
8
  it "uses 'Double' in failure messages" do
@@ -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 eq :received }
88
+ @double.should_receive(:msg).with {|arg| expect(arg).to 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,59 +6,59 @@ module RSpec
6
6
  describe HashExcludingMatcher do
7
7
 
8
8
  it "describes itself properly" do
9
- HashExcludingMatcher.new(:a => 5).description.should eq "hash_not_including(:a=>5)"
9
+ expect(HashExcludingMatcher.new(:a => 5).description).to 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 eq({:a => 1, :b => 2})
14
+ expect(hash_not_including(:c)).to 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 eq({:a => 1, :b => 2})
18
+ expect(hash_not_including(:b => 3)).to 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 eq({:a => 1, :b => 2})
22
+ expect(hash_not_including(:c => anything)).to eq({:a => 1, :b => 2})
23
23
  end
24
24
 
25
25
  it "matches an empty hash" do
26
- hash_not_including(:a).should eq({})
26
+ expect(hash_not_including(:a)).to 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 eq({ :d => 7})
30
+ expect(hash_not_including(:a, :b, :c)).to eq(:d => 7)
31
31
  end
32
32
 
33
33
  end
34
34
 
35
35
  describe "failing" do
36
36
  it "does not match a non-hash" do
37
- hash_not_including(:a => 1).should_not == 1
37
+ expect(hash_not_including(:a => 1)).not_to eq 1
38
38
  end
39
39
 
40
40
  it "does not match a hash with a specified key" do
41
- hash_not_including(:b).should_not == {:b => 2}
41
+ expect(hash_not_including(:b)).not_to eq(:b => 2)
42
42
  end
43
43
 
44
44
  it "does not match a hash with the specified key/value pair" do
45
- hash_not_including(:b => 2).should_not == {:a => 1, :b => 2}
45
+ expect(hash_not_including(:b => 2)).not_to eq(:a => 1, :b => 2)
46
46
  end
47
47
 
48
48
  it "does not match a hash with the specified key" do
49
- hash_not_including(:a, :b => 3).should_not == {:a => 1, :b => 2}
49
+ expect(hash_not_including(:a, :b => 3)).not_to eq(:a => 1, :b => 2)
50
50
  end
51
51
 
52
52
  it "does not match a hash with one of the specified keys" do
53
- hash_not_including(:a, :b).should_not == {:b => 2}
53
+ expect(hash_not_including(:a, :b)).not_to eq(:b => 2)
54
54
  end
55
55
 
56
56
  it "does not match a hash with some of the specified keys" do
57
- hash_not_including(:a, :b, :c).should_not == {:a => 1, :b => 2}
57
+ expect(hash_not_including(:a, :b, :c)).not_to eq(:a => 1, :b => 2)
58
58
  end
59
59
 
60
60
  it "does not match a hash with one key/value pair included" do
61
- hash_not_including(:a, :b, :c, :d => 7).should_not == { :d => 7}
61
+ expect(hash_not_including(:a, :b, :c, :d => 7)).not_to eq(:d => 7)
62
62
  end
63
63
  end
64
64
  end
@@ -4,84 +4,84 @@ module RSpec
4
4
  module Mocks
5
5
  module ArgumentMatchers
6
6
  describe HashIncludingMatcher do
7
-
7
+
8
8
  it "describes itself properly" do
9
- HashIncludingMatcher.new(:a => 1).description.should eq "hash_including(:a=>1)"
10
- end
9
+ expect(HashIncludingMatcher.new(:a => 1).description).to eq "hash_including(:a=>1)"
10
+ end
11
11
 
12
12
  describe "passing" do
13
13
  it "matches the same hash" do
14
- hash_including(:a => 1).should eq({:a => 1})
14
+ expect(hash_including(:a => 1)).to eq({:a => 1})
15
15
  end
16
16
 
17
17
  it "matches a hash with extra stuff" do
18
- hash_including(:a => 1).should eq({:a => 1, :b => 2})
18
+ expect(hash_including(:a => 1)).to 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 eq({:a => 1, :b => 2})
23
+ expect(hash_including(:a => anything, :b => 2)).to 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 eq({:a => "1", :b => 2})
27
+ expect(hash_including(:a => anything, :b => 2)).to 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 eq({:a => 1, :b => 2})
33
+ expect(hash_including(:a)).to 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 eq({:a => 1, :b => 2, :c => 3})
37
+ expect(hash_including(:a, :b)).to 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 eq({:a => "1", :b => 2})
41
+ expect(hash_including(:a)).to 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 eq({:a => 1, :b => 2})
45
+ expect(hash_including(:a, :b => 2)).to 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 eq({:a => 1, :b => 2, :c => 3, :d => 4})
49
+ expect(hash_including(:a, :b, :c => 3)).to 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 eq({:a => 1, :b => 2, :c => 3, :d => 4, :e => 5})
53
+ expect(hash_including(:a, :b, :c => 3, :e => 5)).to eq({:a => 1, :b => 2, :c => 3, :d => 4, :e => 5})
54
54
  end
55
55
  end
56
56
  end
57
-
57
+
58
58
  describe "failing" do
59
59
  it "does not match a non-hash" do
60
- hash_including(:a => 1).should_not == 1
60
+ expect(hash_including(:a => 1)).not_to eq 1
61
61
  end
62
62
 
63
63
  it "does not match a hash with a missing key" do
64
- hash_including(:a => 1).should_not == {:b => 2}
64
+ expect(hash_including(:a => 1)).not_to eq(:b => 2)
65
65
  end
66
-
66
+
67
67
  it "does not match a hash with a missing key" do
68
- hash_including(:a).should_not == {:b => 2}
68
+ expect(hash_including(:a)).not_to eq(:b => 2)
69
69
  end
70
-
70
+
71
71
  it "does not match an empty hash with a given key" do
72
- hash_including(:a).should_not == {}
72
+ expect(hash_including(:a)).not_to eq({})
73
73
  end
74
-
74
+
75
75
  it "does not match a hash with a missing key when one pair is matching" do
76
- hash_including(:a, :b => 2).should_not == {:b => 2}
76
+ expect(hash_including(:a, :b => 2)).not_to eq(:b => 2)
77
77
  end
78
-
78
+
79
79
  it "does not match a hash with an incorrect value" do
80
- hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3}
80
+ expect(hash_including(:a => 1, :b => 2)).not_to eq(:a => 1, :b => 3)
81
81
  end
82
82
 
83
83
  it "does not match when values are nil but keys are different" do
84
- hash_including(:a => nil).should_not == {:b => nil}
84
+ expect(hash_including(:a => nil)).not_to eq(:b => nil)
85
85
  end
86
86
  end
87
87
  end