rspec-mocks 2.0.0.beta.19 → 2.0.0.beta.20

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 (44) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +0 -7
  3. data/VERSION +1 -1
  4. data/lib/rspec/mocks/argument_expectation.rb +7 -10
  5. data/lib/rspec/mocks/extensions/instance_exec.rb +3 -3
  6. data/lib/rspec/mocks/message_expectation.rb +26 -26
  7. data/lib/rspec/mocks/methods.rb +22 -6
  8. data/lib/rspec/mocks/mock.rb +3 -3
  9. data/lib/rspec/mocks/proxy.rb +10 -10
  10. data/rspec-mocks.gemspec +9 -15
  11. data/spec/rspec/mocks/any_number_of_times_spec.rb +4 -4
  12. data/spec/rspec/mocks/argument_expectation_spec.rb +4 -4
  13. data/spec/rspec/mocks/at_least_spec.rb +11 -11
  14. data/spec/rspec/mocks/at_most_spec.rb +11 -11
  15. data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
  16. data/spec/rspec/mocks/bug_report_11545_spec.rb +3 -3
  17. data/spec/rspec/mocks/bug_report_15719_spec.rb +2 -2
  18. data/spec/rspec/mocks/bug_report_600_spec.rb +2 -2
  19. data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
  20. data/spec/rspec/mocks/bug_report_8165_spec.rb +2 -2
  21. data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
  22. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +12 -12
  23. data/spec/rspec/mocks/hash_including_matcher_spec.rb +18 -18
  24. data/spec/rspec/mocks/hash_not_including_matcher_spec.rb +13 -13
  25. data/spec/rspec/mocks/mock_ordering_spec.rb +7 -7
  26. data/spec/rspec/mocks/mock_space_spec.rb +4 -4
  27. data/spec/rspec/mocks/mock_spec.rb +65 -65
  28. data/spec/rspec/mocks/multiple_return_value_spec.rb +11 -11
  29. data/spec/rspec/mocks/nil_expectation_warning_spec.rb +4 -4
  30. data/spec/rspec/mocks/null_object_mock_spec.rb +7 -7
  31. data/spec/rspec/mocks/once_counts_spec.rb +6 -6
  32. data/spec/rspec/mocks/options_hash_spec.rb +3 -3
  33. data/spec/rspec/mocks/partial_mock_spec.rb +17 -17
  34. data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
  35. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +20 -20
  36. data/spec/rspec/mocks/precise_counts_spec.rb +5 -5
  37. data/spec/rspec/mocks/record_messages_spec.rb +4 -4
  38. data/spec/rspec/mocks/stash_spec.rb +1 -1
  39. data/spec/rspec/mocks/stub_chain_spec.rb +13 -0
  40. data/spec/rspec/mocks/stub_implementation_spec.rb +4 -4
  41. data/spec/rspec/mocks/stub_spec.rb +26 -26
  42. data/spec/spec_helper.rb +2 -2
  43. data/spec/support/macros.rb +2 -2
  44. metadata +17 -27
@@ -7,7 +7,7 @@ module RSpec
7
7
  @mock = RSpec::Mocks::Mock.new("test mock")
8
8
  end
9
9
 
10
- it "should fail when at most n times method is called n plus 1 times" do
10
+ it "fails when at most n times method is called n plus 1 times" do
11
11
  @mock.should_receive(:random_call).at_most(4).times
12
12
  @mock.random_call
13
13
  @mock.random_call
@@ -19,7 +19,7 @@ module RSpec
19
19
  end.should raise_error(RSpec::Mocks::MockExpectationError)
20
20
  end
21
21
 
22
- it "should fail when at most once method is called twice" do
22
+ it "fails when at most once method is called twice" do
23
23
  @mock.should_receive(:random_call).at_most(:once)
24
24
  @mock.random_call
25
25
  @mock.random_call
@@ -28,7 +28,7 @@ module RSpec
28
28
  end.should raise_error(RSpec::Mocks::MockExpectationError)
29
29
  end
30
30
 
31
- it "should fail when at most twice method is called three times" do
31
+ it "fails when at most twice method is called three times" do
32
32
  @mock.should_receive(:random_call).at_most(:twice)
33
33
  @mock.random_call
34
34
  @mock.random_call
@@ -38,7 +38,7 @@ module RSpec
38
38
  end.should raise_error(RSpec::Mocks::MockExpectationError)
39
39
  end
40
40
 
41
- it "should pass when at most n times method is called exactly n times" do
41
+ it "passes when at most n times method is called exactly n times" do
42
42
  @mock.should_receive(:random_call).at_most(4).times
43
43
  @mock.random_call
44
44
  @mock.random_call
@@ -47,7 +47,7 @@ module RSpec
47
47
  @mock.rspec_verify
48
48
  end
49
49
 
50
- it "should pass when at most n times method is called less than n times" do
50
+ it "passes when at most n times method is called less than n times" do
51
51
  @mock.should_receive(:random_call).at_most(4).times
52
52
  @mock.random_call
53
53
  @mock.random_call
@@ -55,36 +55,36 @@ module RSpec
55
55
  @mock.rspec_verify
56
56
  end
57
57
 
58
- it "should pass when at most n times method is never called" do
58
+ it "passes when at most n times method is never called" do
59
59
  @mock.should_receive(:random_call).at_most(4).times
60
60
  @mock.rspec_verify
61
61
  end
62
62
 
63
- it "should pass when at most once method is called once" do
63
+ it "passes when at most once method is called once" do
64
64
  @mock.should_receive(:random_call).at_most(:once)
65
65
  @mock.random_call
66
66
  @mock.rspec_verify
67
67
  end
68
68
 
69
- it "should pass when at most once method is never called" do
69
+ it "passes when at most once method is never called" do
70
70
  @mock.should_receive(:random_call).at_most(:once)
71
71
  @mock.rspec_verify
72
72
  end
73
73
 
74
- it "should pass when at most twice method is called once" do
74
+ it "passes when at most twice method is called once" do
75
75
  @mock.should_receive(:random_call).at_most(:twice)
76
76
  @mock.random_call
77
77
  @mock.rspec_verify
78
78
  end
79
79
 
80
- it "should pass when at most twice method is called twice" do
80
+ it "passes when at most twice method is called twice" do
81
81
  @mock.should_receive(:random_call).at_most(:twice)
82
82
  @mock.random_call
83
83
  @mock.random_call
84
84
  @mock.rspec_verify
85
85
  end
86
86
 
87
- it "should pass when at most twice method is never called" do
87
+ it "passes when at most twice method is never called" do
88
88
  @mock.should_receive(:random_call).at_most(:twice)
89
89
  @mock.rspec_verify
90
90
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "An RSpec Mock" do
4
- it "should hide internals in its inspect representation" do
4
+ it "hides internals in its inspect representation" do
5
5
  m = double('cup')
6
6
  m.inspect.should =~ /#<RSpec::Mocks::Mock:0x[a-f0-9.]+ @name="cup">/
7
7
  end
@@ -15,17 +15,17 @@ describe 'should_receive' do
15
15
  @liar = LiarLiarPantsOnFire.new
16
16
  end
17
17
 
18
- it "should work when object lies about responding to a method" do
18
+ it "works when object lies about responding to a method" do
19
19
  @liar.should_receive(:something)
20
20
  @liar.something
21
21
  end
22
22
 
23
- it 'should work when class lies about responding to a method' do
23
+ it 'works when class lies about responding to a method' do
24
24
  LiarLiarPantsOnFire.should_receive(:something)
25
25
  LiarLiarPantsOnFire.something
26
26
  end
27
27
 
28
- it 'should cleanup after itself' do
28
+ it 'cleans up after itself' do
29
29
  (class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something")
30
30
  end
31
31
  end
@@ -4,7 +4,7 @@ module RSpec
4
4
  module Mocks
5
5
  describe "mock failure" do
6
6
 
7
- it "should tell you when it receives the right message with the wrong args" do
7
+ it "tells you when it receives the right message with the wrong args" do
8
8
  double = double("foo")
9
9
  double.should_receive(:bar).with("message")
10
10
  lambda {
@@ -13,7 +13,7 @@ module RSpec
13
13
  double.rspec_reset # so the example doesn't fail
14
14
  end
15
15
 
16
- pending "should tell you when it receives the right message with the wrong args if you stub the method (fix bug 15719)" do
16
+ pending "tells you when it receives the right message with the wrong args if you stub the method (fix bug 15719)" do
17
17
  # NOTE - for whatever reason, if you use a the block style of pending here,
18
18
  # rcov gets unhappy. Don't know why yet.
19
19
  double = double("foo")
@@ -10,12 +10,12 @@ module BugReport600
10
10
  end
11
11
  end
12
12
 
13
- it "should work" do
13
+ it "works" do
14
14
  ExampleClass.should_receive(:define_method).with("defined_method")
15
15
  ExampleClass.method_that_uses_define_method
16
16
  end
17
17
 
18
- it "should restore the original method" do
18
+ it "restores the original method" do
19
19
  ExampleClass.method_that_uses_define_method
20
20
  end
21
21
  end
@@ -7,7 +7,7 @@ module Bug7611
7
7
 
8
8
  class Bar < Foo
9
9
  end
10
- it "should respect subclasses" do
10
+ it "respects subclasses" do
11
11
  Foo.stub(:new).and_return(Object.new)
12
12
  end
13
13
 
@@ -12,7 +12,7 @@ describe "An object where respond_to? is true and does not have method" do
12
12
  # The fix was to keep track of whether :respond_to? had been proxied and, if
13
13
  # so, call the munged copy of :respond_to? on the object.
14
14
 
15
- it "should not raise an exception for Object" do
15
+ it "does not raise an exception for Object" 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)
@@ -20,7 +20,7 @@ describe "An object where respond_to? is true and does not have method" do
20
20
  obj.foobar.should == :baz
21
21
  end
22
22
 
23
- it "should not raise an exception for mock" do
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)
@@ -10,11 +10,11 @@ module RSpec
10
10
  @base_class.stub(:find).and_return "stubbed_value"
11
11
  end
12
12
 
13
- it "should return the value for the stub on the base class" do
13
+ it "returns the value for the stub on the base class" do
14
14
  @base_class.find.should == "stubbed_value"
15
15
  end
16
16
 
17
- it "should return the value for the descendent class" do
17
+ it "returns the value for the descendent class" do
18
18
  @concrete_class.find.should == "stubbed_value"
19
19
  end
20
20
  end
@@ -12,78 +12,78 @@ module RSpec
12
12
  @mock.rspec_reset
13
13
  end
14
14
 
15
- it "should reject non boolean" do
15
+ it "rejects non boolean" do
16
16
  @mock.should_receive(:random_call).with(boolean())
17
17
  lambda do
18
18
  @mock.random_call("false")
19
19
  end.should raise_error(RSpec::Mocks::MockExpectationError)
20
20
  end
21
21
 
22
- it "should reject non numeric" do
22
+ it "rejects non numeric" do
23
23
  @mock.should_receive(:random_call).with(an_instance_of(Numeric))
24
24
  lambda do
25
25
  @mock.random_call("1")
26
26
  end.should raise_error(RSpec::Mocks::MockExpectationError)
27
27
  end
28
28
 
29
- it "should reject non string" do
29
+ it "rejects non string" do
30
30
  @mock.should_receive(:random_call).with(an_instance_of(String))
31
31
  lambda do
32
32
  @mock.random_call(123)
33
33
  end.should raise_error(RSpec::Mocks::MockExpectationError)
34
34
  end
35
35
 
36
- it "should reject goose when expecting a duck" do
36
+ it "rejects goose when expecting a duck" do
37
37
  @mock.should_receive(:random_call).with(duck_type(:abs, :div))
38
38
  lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(RSpec::Mocks::MockExpectationError)
39
39
  end
40
40
 
41
- it "should fail if regexp does not match submitted string" do
41
+ it "fails if regexp does not match submitted string" do
42
42
  @mock.should_receive(:random_call).with(/bcd/)
43
43
  lambda { @mock.random_call("abc") }.should raise_error(RSpec::Mocks::MockExpectationError)
44
44
  end
45
45
 
46
- it "should fail if regexp does not match submitted regexp" do
46
+ it "fails if regexp does not match submitted regexp" do
47
47
  @mock.should_receive(:random_call).with(/bcd/)
48
48
  lambda { @mock.random_call(/bcde/) }.should raise_error(RSpec::Mocks::MockExpectationError)
49
49
  end
50
50
 
51
- it "should fail for a hash w/ wrong values" do
51
+ it "fails for a hash w/ wrong values" do
52
52
  @mock.should_receive(:random_call).with(:a => "b", :c => "d")
53
53
  lambda do
54
54
  @mock.random_call(:a => "b", :c => "e")
55
55
  end.should raise_error(RSpec::Mocks::MockExpectationError, /Double "test double" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
56
56
  end
57
57
 
58
- it "should fail for a hash w/ wrong keys" do
58
+ it "fails for a hash w/ wrong keys" do
59
59
  @mock.should_receive(:random_call).with(:a => "b", :c => "d")
60
60
  lambda do
61
61
  @mock.random_call("a" => "b", "c" => "d")
62
62
  end.should raise_error(RSpec::Mocks::MockExpectationError, /Double "test double" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
63
63
  end
64
64
 
65
- it "should match against a Matcher" do
65
+ it "matches against a Matcher" do
66
66
  lambda do
67
67
  @mock.should_receive(:msg).with(equal(3))
68
68
  @mock.msg(37)
69
69
  end.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :msg with unexpected arguments\n expected: (equal 3)\n got: (37)")
70
70
  end
71
71
 
72
- it "should fail no_args with one arg" do
72
+ it "fails no_args with one arg" do
73
73
  lambda do
74
74
  @mock.should_receive(:msg).with(no_args)
75
75
  @mock.msg(37)
76
76
  end.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :msg with unexpected arguments\n expected: (no args)\n got: (37)")
77
77
  end
78
78
 
79
- it "should fail hash_including with missing key" do
79
+ it "fails hash_including with missing key" do
80
80
  lambda do
81
81
  @mock.should_receive(:msg).with(hash_including(:a => 1))
82
82
  @mock.msg({})
83
83
  end.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :msg with unexpected arguments\n expected: (hash_including(:a=>1))\n got: ({})")
84
84
  end
85
85
 
86
- it "should fail with block matchers" do
86
+ it "fails with block matchers" do
87
87
  lambda do
88
88
  @mock.should_receive(:msg).with {|arg| arg.should == :received }
89
89
  @mock.msg :no_msg_for_you
@@ -5,82 +5,82 @@ module RSpec
5
5
  module ArgumentMatchers
6
6
  describe HashIncludingMatcher do
7
7
 
8
- it "should describe itself properly" do
8
+ it "describes itself properly" do
9
9
  HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)"
10
10
  end
11
11
 
12
12
  describe "passing" do
13
- it "should match the same hash" do
13
+ it "matches the same hash" do
14
14
  hash_including(:a => 1).should == {:a => 1}
15
15
  end
16
16
 
17
- it "should match a hash with extra stuff" do
17
+ it "matches a hash with extra stuff" do
18
18
  hash_including(:a => 1).should == {:a => 1, :b => 2}
19
19
  end
20
20
 
21
21
  describe "when matching against other matchers" do
22
- it "should match an int against anything()" do
22
+ it "matches an int against anything()" do
23
23
  hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2}
24
24
  end
25
25
 
26
- it "should match a string against anything()" do
26
+ it "matches a string against anything()" do
27
27
  hash_including(:a => anything, :b => 2).should == {: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
- it "should match if the key is present" do
32
+ it "matches if the key is present" do
33
33
  hash_including(:a).should == {:a => 1, :b => 2}
34
34
  end
35
35
 
36
- it "should match if more keys are present" do
36
+ it "matches if more keys are present" do
37
37
  hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3}
38
38
  end
39
39
 
40
- it "should match a string against a given key" do
40
+ it "matches a string against a given key" do
41
41
  hash_including(:a).should == {:a => "1", :b => 2}
42
42
  end
43
43
 
44
- it "should match if passed one key and one key/value pair" do
44
+ it "matches if passed one key and one key/value pair" do
45
45
  hash_including(:a, :b => 2).should == {:a => 1, :b => 2}
46
46
  end
47
47
 
48
- it "should match if passed many keys and one key/value pair" do
48
+ it "matches if passed many keys and one key/value pair" do
49
49
  hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4}
50
50
  end
51
51
 
52
- it "should match if passed many keys and many key/value pairs" do
52
+ it "matches if passed many keys and many key/value pairs" do
53
53
  hash_including(:a, :b, :c => 3, :e => 5).should == {: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
- it "should not match a non-hash" do
59
+ it "does not match a non-hash" do
60
60
  hash_including(:a => 1).should_not == 1
61
61
  end
62
62
 
63
- it "should not match a hash with a missing key" do
63
+ it "does not match a hash with a missing key" do
64
64
  hash_including(:a => 1).should_not == {:b => 2}
65
65
  end
66
66
 
67
- it "should not match a hash with a missing key" do
67
+ it "does not match a hash with a missing key" do
68
68
  hash_including(:a).should_not == {:b => 2}
69
69
  end
70
70
 
71
- it "should not match an empty hash with a given key" do
71
+ it "does not match an empty hash with a given key" do
72
72
  hash_including(:a).should_not == {}
73
73
  end
74
74
 
75
- it "should not match a hash with a missing key when one pair is matching" do
75
+ it "does not match a hash with a missing key when one pair is matching" do
76
76
  hash_including(:a, :b => 2).should_not == {:b => 2}
77
77
  end
78
78
 
79
- it "should not match a hash with an incorrect value" do
79
+ it "does not match a hash with an incorrect value" do
80
80
  hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3}
81
81
  end
82
82
 
83
- it "should not match when values are nil but keys are different" do
83
+ it "does not match when values are nil but keys are different" do
84
84
  hash_including(:a => nil).should_not == {:b => nil}
85
85
  end
86
86
  end
@@ -5,59 +5,59 @@ module RSpec
5
5
  module ArgumentMatchers
6
6
  describe HashNotIncludingMatcher do
7
7
 
8
- it "should describe itself properly" do
8
+ it "describes itself properly" do
9
9
  HashNotIncludingMatcher.new(:a => 5).description.should == "hash_not_including(:a=>5)"
10
10
  end
11
11
 
12
12
  describe "passing" do
13
- it "should match a hash without the specified key" do
13
+ it "matches a hash without the specified key" do
14
14
  hash_not_including(:c).should == {:a => 1, :b => 2}
15
15
  end
16
16
 
17
- it "should match a hash with the specified key, but different value" do
17
+ it "matches a hash with the specified key, but different value" do
18
18
  hash_not_including(:b => 3).should == {:a => 1, :b => 2}
19
19
  end
20
20
 
21
- it "should match a hash without the specified key, given as anything()" do
21
+ it "matches a hash without the specified key, given as anything()" do
22
22
  hash_not_including(:c => anything).should == {:a => 1, :b => 2}
23
23
  end
24
24
 
25
- it "should match an empty hash" do
25
+ it "matches an empty hash" do
26
26
  hash_not_including(:a).should == {}
27
27
  end
28
28
 
29
- it "should match a hash without any of the specified keys" do
29
+ it "matches a hash without any of the specified keys" do
30
30
  hash_not_including(:a, :b, :c).should == { :d => 7}
31
31
  end
32
32
 
33
33
  end
34
34
 
35
35
  describe "failing" do
36
- it "should not match a non-hash" do
36
+ it "does not match a non-hash" do
37
37
  hash_not_including(:a => 1).should_not == 1
38
38
  end
39
39
 
40
- it "should not match a hash with a specified key" do
40
+ it "does not match a hash with a specified key" do
41
41
  hash_not_including(:b).should_not == {:b => 2}
42
42
  end
43
43
 
44
- it "should not match a hash with the specified key/value pair" do
44
+ it "does not match a hash with the specified key/value pair" do
45
45
  hash_not_including(:b => 2).should_not == {:a => 1, :b => 2}
46
46
  end
47
47
 
48
- it "should not match a hash with the specified key" do
48
+ it "does not match a hash with the specified key" do
49
49
  hash_not_including(:a, :b => 3).should_not == {:a => 1, :b => 2}
50
50
  end
51
51
 
52
- it "should not match a hash with one of the specified keys" do
52
+ it "does not match a hash with one of the specified keys" do
53
53
  hash_not_including(:a, :b).should_not == {:b => 2}
54
54
  end
55
55
 
56
- it "should not match a hash with some of the specified keys" do
56
+ it "does not match a hash with some of the specified keys" do
57
57
  hash_not_including(:a, :b, :c).should_not == {:a => 1, :b => 2}
58
58
  end
59
59
 
60
- it "should not match a hash with one key/value pair included" do
60
+ it "does not match a hash with one key/value pair included" do
61
61
  hash_not_including(:a, :b, :c, :d => 7).should_not == { :d => 7}
62
62
  end
63
63
  end