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

Sign up to get free protection for your applications and to get access to all the features.
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 = double("test mock")
8
8
  end
9
9
 
10
- it "should fail when exactly n times method is called less than n times" do
10
+ it "fails when exactly n times method is called less than n times" do
11
11
  @mock.should_receive(:random_call).exactly(3).times
12
12
  @mock.random_call
13
13
  @mock.random_call
@@ -16,14 +16,14 @@ module RSpec
16
16
  end.should raise_error(RSpec::Mocks::MockExpectationError)
17
17
  end
18
18
 
19
- it "should fail when exactly n times method is never called" do
19
+ it "fails when exactly n times method is never called" do
20
20
  @mock.should_receive(:random_call).exactly(3).times
21
21
  lambda do
22
22
  @mock.rspec_verify
23
23
  end.should raise_error(RSpec::Mocks::MockExpectationError)
24
24
  end
25
25
 
26
- it "should pass if exactly n times method is called exactly n times" do
26
+ it "passes if exactly n times method is called exactly n times" do
27
27
  @mock.should_receive(:random_call).exactly(3).times
28
28
  @mock.random_call
29
29
  @mock.random_call
@@ -31,7 +31,7 @@ module RSpec
31
31
  @mock.rspec_verify
32
32
  end
33
33
 
34
- it "should pass multiple calls with different args and counts" do
34
+ it "passes multiple calls with different args and counts" do
35
35
  @mock.should_receive(:random_call).twice.with(1)
36
36
  @mock.should_receive(:random_call).once.with(2)
37
37
  @mock.random_call(1)
@@ -40,7 +40,7 @@ module RSpec
40
40
  @mock.rspec_verify
41
41
  end
42
42
 
43
- it "should pass mutiple calls with different args" do
43
+ it "passes mutiple calls with different args" do
44
44
  @mock.should_receive(:random_call).once.with(1)
45
45
  @mock.should_receive(:random_call).once.with(2)
46
46
  @mock.random_call(1)
@@ -6,18 +6,18 @@ module RSpec
6
6
  before(:each) do
7
7
  @mock = double("mock").as_null_object
8
8
  end
9
- it "should answer false for received_message? when no messages received" do
9
+ it "answers false for received_message? when no messages received" do
10
10
  @mock.received_message?(:message).should be_false
11
11
  end
12
- it "should answer true for received_message? when message received" do
12
+ it "answers true for received_message? when message received" do
13
13
  @mock.message
14
14
  @mock.received_message?(:message).should be_true
15
15
  end
16
- it "should answer true for received_message? when message received with correct args" do
16
+ it "answers true for received_message? when message received with correct args" do
17
17
  @mock.message 1,2,3
18
18
  @mock.received_message?(:message, 1,2,3).should be_true
19
19
  end
20
- it "should answer false for received_message? when message received with incorrect args" do
20
+ it "answers false for received_message? when message received with incorrect args" do
21
21
  @mock.message 1,2,3
22
22
  @mock.received_message?(:message, 1,2).should be_false
23
23
  end
@@ -11,7 +11,7 @@ module RSpec
11
11
  end
12
12
  end
13
13
  end
14
- it "should keep the original method intact after multiple expectations are added on the same method" do
14
+ it "keeps the original method intact after multiple expectations are added on the same method" do
15
15
  klass.should_receive(:foo).with(:fizbaz).and_return(:wowwow)
16
16
  klass.should_receive(:foo).with(:bazbar).and_return(:okay)
17
17
 
@@ -29,6 +29,19 @@ module RSpec
29
29
  @subject.msg1.msg2.msg3.msg4.should equal(:first)
30
30
  @subject.msg5.msg2.msg3.msg4.should equal(:second)
31
31
  end
32
+
33
+ it "returns expected value when chain is a dot separated string, like stub_chain('msg1.msg2.msg3')" do
34
+ @subject.stub_chain("msg1.msg2.msg3").and_return(:return_value)
35
+ @subject.msg1.msg2.msg3.should equal(:return_value)
36
+ end
37
+
38
+ it "returns expected value from two chains with shared messages at the beginning" do
39
+ @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:first)
40
+ @subject.stub_chain(:msg1, :msg2, :msg3, :msg5).and_return(:second)
41
+
42
+ @subject.msg1.msg2.msg3.msg4.should equal(:first)
43
+ @subject.msg1.msg2.msg3.msg5.should equal(:second)
44
+ end
32
45
  end
33
46
  end
34
47
  end
@@ -30,7 +30,7 @@ module RSpec
30
30
 
31
31
 
32
32
  describe "unstub implementation" do
33
- it "should replace the stubbed method with the original method" do
33
+ it "replaces the stubbed method with the original method" do
34
34
  obj = Object.new
35
35
  def obj.foo; :original; end
36
36
  obj.stub(:foo)
@@ -38,7 +38,7 @@ module RSpec
38
38
  obj.foo.should == :original
39
39
  end
40
40
 
41
- it "should remove all stubs with the supplied method name" do
41
+ it "removes all stubs with the supplied method name" do
42
42
  obj = Object.new
43
43
  def obj.foo; :original; end
44
44
  obj.stub(:foo).with(1)
@@ -47,7 +47,7 @@ module RSpec
47
47
  obj.foo.should == :original
48
48
  end
49
49
 
50
- it "should not remove any expectations with the same method name" do
50
+ it "does not remove any expectations with the same method name" do
51
51
  obj = Object.new
52
52
  def obj.foo; :original; end
53
53
  obj.should_receive(:foo).with(3).and_return(:three)
@@ -57,7 +57,7 @@ module RSpec
57
57
  obj.foo(3).should == :three
58
58
  end
59
59
 
60
- it "should raise a MockExpectationError if the method has not been stubbed" do
60
+ it "raises a MockExpectationError if the method has not been stubbed" do
61
61
  obj = Object.new
62
62
  lambda do
63
63
  obj.unstub(:foo)
@@ -31,7 +31,7 @@ module RSpec
31
31
 
32
32
  [:stub!, :stub].each do |method|
33
33
  describe "using #{method}" do
34
- it "should return expected value when expected message is received" do
34
+ it "returns expected value when expected message is received" do
35
35
  @instance.send(method, :msg).and_return(:return_value)
36
36
  @instance.msg.should equal(:return_value)
37
37
  @instance.rspec_verify
@@ -39,7 +39,7 @@ module RSpec
39
39
  end
40
40
  end
41
41
 
42
- it "should ignore when expected message is received" do
42
+ it "ignores when expected message is received" do
43
43
  @instance.stub(:msg)
44
44
  @instance.msg
45
45
  lambda do
@@ -47,7 +47,7 @@ module RSpec
47
47
  end.should_not raise_error
48
48
  end
49
49
 
50
- it "should ignore when message is received with args" do
50
+ it "ignores when message is received with args" do
51
51
  @instance.stub(:msg)
52
52
  @instance.msg(:an_arg)
53
53
  lambda do
@@ -55,20 +55,20 @@ module RSpec
55
55
  end.should_not raise_error
56
56
  end
57
57
 
58
- it "should ignore when expected message is not received" do
58
+ it "ignores when expected message is not received" do
59
59
  @instance.stub(:msg)
60
60
  lambda do
61
61
  @instance.rspec_verify
62
62
  end.should_not raise_error
63
63
  end
64
64
 
65
- it "should handle multiple stubbed methods" do
65
+ it "handles multiple stubbed methods" do
66
66
  @instance.stub(:msg1 => 1, :msg2 => 2)
67
67
  @instance.msg1.should == 1
68
68
  @instance.msg2.should == 2
69
69
  end
70
70
 
71
- it "should clear itself when verified" do
71
+ it "clears itself when verified" do
72
72
  @instance.stub(:this_should_go).and_return(:blah)
73
73
  @instance.this_should_go.should == :blah
74
74
  @instance.rspec_verify
@@ -77,7 +77,7 @@ module RSpec
77
77
  end.should raise_error(NameError)
78
78
  end
79
79
 
80
- it "should return values in order to consecutive calls" do
80
+ it "returns values in order to consecutive calls" do
81
81
  return_values = ["1",2,Object.new]
82
82
  @instance.stub(:msg).and_return(*return_values)
83
83
  @instance.msg.should == return_values[0]
@@ -85,7 +85,7 @@ module RSpec
85
85
  @instance.msg.should == return_values[2]
86
86
  end
87
87
 
88
- it "should keep returning last value in consecutive calls" do
88
+ it "keeps returning last value in consecutive calls" do
89
89
  return_values = ["1",2,Object.new]
90
90
  @instance.stub(:msg).and_return(return_values[0],return_values[1],return_values[2])
91
91
  @instance.msg.should == return_values[0]
@@ -95,7 +95,7 @@ module RSpec
95
95
  @instance.msg.should == return_values[2]
96
96
  end
97
97
 
98
- it "should revert to original instance method if there is one" do
98
+ it "reverts to original instance method if there is one" do
99
99
  @instance.existing_instance_method.should equal(:original_value)
100
100
  @instance.stub(:existing_instance_method).and_return(:mock_value)
101
101
  @instance.existing_instance_method.should equal(:mock_value)
@@ -103,7 +103,7 @@ module RSpec
103
103
  @instance.existing_instance_method.should equal(:original_value)
104
104
  end
105
105
 
106
- it "should revert to original private instance method if there is one" do
106
+ it "reverts to original private instance method if there is one" do
107
107
  @instance.existing_instance_method.should equal(:original_value)
108
108
  @instance.stub(:existing_private_instance_method).and_return(:mock_value)
109
109
  @instance.existing_instance_method.should equal(:mock_value)
@@ -111,7 +111,7 @@ module RSpec
111
111
  @instance.existing_instance_method.should equal(:original_value)
112
112
  end
113
113
 
114
- it "should revert to original class method if there is one" do
114
+ it "reverts to original class method if there is one" do
115
115
  @class.existing_class_method.should equal(:original_value)
116
116
  @class.stub(:existing_class_method).and_return(:mock_value)
117
117
  @class.existing_class_method.should equal(:mock_value)
@@ -119,7 +119,7 @@ module RSpec
119
119
  @class.existing_class_method.should equal(:original_value)
120
120
  end
121
121
 
122
- it "should revert to original private class method if there is one" do
122
+ it "reverts to original private class method if there is one" do
123
123
  @class.existing_class_method.should equal(:original_value)
124
124
  @class.stub(:existing_private_class_method).and_return(:mock_value)
125
125
  @class.existing_class_method.should equal(:mock_value)
@@ -127,7 +127,7 @@ module RSpec
127
127
  @class.existing_class_method.should equal(:original_value)
128
128
  end
129
129
 
130
- it "should yield a specified object" do
130
+ it "yields a specified object" do
131
131
  @instance.stub(:method_that_yields).and_yield(:yielded_obj)
132
132
  current_value = :value_before
133
133
  @instance.method_that_yields {|val| current_value = val}
@@ -135,7 +135,7 @@ module RSpec
135
135
  @instance.rspec_verify
136
136
  end
137
137
 
138
- it "should yield multiple times with multiple calls to and_yield" do
138
+ it "yields multiple times with multiple calls to and_yield" do
139
139
  @instance.stub(:method_that_yields_multiple_times).and_yield(:yielded_value).
140
140
  and_yield(:another_value)
141
141
  current_value = []
@@ -144,32 +144,32 @@ module RSpec
144
144
  @instance.rspec_verify
145
145
  end
146
146
 
147
- it "should yield a specified object and return another specified object" do
147
+ it "yields a specified object and return another specified object" do
148
148
  yielded_obj = double("my mock")
149
149
  yielded_obj.should_receive(:foo).with(:bar)
150
150
  @instance.stub(:method_that_yields_and_returns).and_yield(yielded_obj).and_return(:baz)
151
151
  @instance.method_that_yields_and_returns { |o| o.foo :bar }.should == :baz
152
152
  end
153
153
 
154
- it "should throw when told to" do
154
+ it "throws when told to" do
155
155
  @stub.stub(:something).and_throw(:up)
156
156
  lambda do
157
157
  @stub.something
158
158
  end.should throw_symbol(:up)
159
159
  end
160
160
 
161
- it "should override a pre-existing method" do
161
+ it "overrides a pre-existing method" do
162
162
  @stub.stub(:existing_instance_method).and_return(:updated_stub_value)
163
163
  @stub.existing_instance_method.should == :updated_stub_value
164
164
  end
165
165
 
166
- it "should override a pre-existing stub" do
166
+ it "overrides a pre-existing stub" do
167
167
  @stub.stub(:foo) { 'bar' }
168
168
  @stub.stub(:foo) { 'baz' }
169
169
  @stub.foo.should == 'baz'
170
170
  end
171
171
 
172
- it "should limit " do
172
+ it "allows a stub and an expectation" do
173
173
  @stub.stub(:foo).with("bar")
174
174
  @stub.should_receive(:foo).with("baz")
175
175
  @stub.foo("bar")
@@ -189,32 +189,32 @@ module RSpec
189
189
  @stub.stub(:foo).with("bar")
190
190
  end
191
191
 
192
- it "should not complain if not called" do
192
+ it "does not complain if not called" do
193
193
  end
194
194
 
195
- it "should not complain if called with arg" do
195
+ it "does not complain if called with arg" do
196
196
  @stub.foo("bar")
197
197
  end
198
198
 
199
- it "should complain if called with no arg" do
199
+ it "complains if called with no arg" do
200
200
  lambda do
201
201
  @stub.foo
202
202
  end.should raise_error
203
203
  end
204
204
 
205
- it "should complain if called with other arg" do
205
+ it "complains if called with other arg" do
206
206
  lambda do
207
207
  @stub.foo("other")
208
208
  end.should raise_error
209
209
  end
210
210
 
211
- it "should not complain if also mocked w/ different args" do
211
+ it "does not complain if also mocked w/ different args" do
212
212
  @stub.should_receive(:foo).with("baz")
213
213
  @stub.foo("bar")
214
214
  @stub.foo("baz")
215
215
  end
216
216
 
217
- it "should complain if also mocked w/ different args AND called w/ a 3rd set of args" do
217
+ it "complains if also mocked w/ different args AND called w/ a 3rd set of args" do
218
218
  @stub.should_receive(:foo).with("baz")
219
219
  @stub.foo("bar")
220
220
  @stub.foo("baz")
@@ -223,7 +223,7 @@ module RSpec
223
223
  end.should raise_error
224
224
  end
225
225
 
226
- it "should support options" do
226
+ it "supports options" do
227
227
  @stub.stub(:foo, :expected_from => "bar")
228
228
  end
229
229
  end
@@ -4,7 +4,7 @@ require 'rspec/expectations'
4
4
 
5
5
  module Macros
6
6
  def treats_method_missing_as_private(options = {:noop => true, :subject => nil})
7
- it "should have method_missing as private" do
7
+ it "has method_missing as private" do
8
8
  with_ruby 1.8 do
9
9
  self.class.describes.private_instance_methods.should include("method_missing")
10
10
  end
@@ -13,7 +13,7 @@ module Macros
13
13
  end
14
14
  end
15
15
 
16
- it "should not respond_to? method_missing (because it's private)" do
16
+ it "does not respond_to? method_missing (because it's private)" do
17
17
  formatter = options[:subject] || described_class.new({ }, StringIO.new)
18
18
  formatter.should_not respond_to(:method_missing)
19
19
  end
@@ -1,6 +1,6 @@
1
1
  module Macros
2
2
  def treats_method_missing_as_private(options = {:noop => true, :subject => nil})
3
- it "should have method_missing as private" do
3
+ it "has method_missing as private" do
4
4
  with_ruby 1.8 do
5
5
  described_class.private_instance_methods.should include("method_missing")
6
6
  end
@@ -9,7 +9,7 @@ module Macros
9
9
  end
10
10
  end
11
11
 
12
- it "should not respond_to? method_missing (because it's private)" do
12
+ it "does not respond_to? method_missing (because it's private)" do
13
13
  formatter = options[:subject] || described_class.new({ }, StringIO.new)
14
14
  formatter.should_not respond_to(:method_missing)
15
15
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-mocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196421
5
4
  prerelease: true
6
5
  segments:
7
6
  - 2
8
7
  - 0
9
8
  - 0
10
9
  - beta
11
- - 19
12
- version: 2.0.0.beta.19
10
+ - 20
11
+ version: 2.0.0.beta.20
13
12
  platform: ruby
14
13
  authors:
15
14
  - David Chelimsky
@@ -18,45 +17,43 @@ autorequire:
18
17
  bindir: bin
19
18
  cert_chain: []
20
19
 
21
- date: 2010-07-25 00:00:00 -05:00
20
+ date: 2010-08-24 00:00:00 -05:00
22
21
  default_executable:
23
22
  dependencies:
24
23
  - !ruby/object:Gem::Dependency
25
- type: :development
26
- prerelease: false
27
24
  name: rspec-core
28
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
29
26
  none: false
30
27
  requirements:
31
28
  - - "="
32
29
  - !ruby/object:Gem::Version
33
- hash: 62196421
34
30
  segments:
35
31
  - 2
36
32
  - 0
37
33
  - 0
38
34
  - beta
39
- - 19
40
- version: 2.0.0.beta.19
41
- requirement: *id001
42
- - !ruby/object:Gem::Dependency
35
+ - 20
36
+ version: 2.0.0.beta.20
43
37
  type: :development
44
38
  prerelease: false
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
45
41
  name: rspec-expectations
46
- version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ requirement: &id002 !ruby/object:Gem::Requirement
47
43
  none: false
48
44
  requirements:
49
45
  - - "="
50
46
  - !ruby/object:Gem::Version
51
- hash: 62196421
52
47
  segments:
53
48
  - 2
54
49
  - 0
55
50
  - 0
56
51
  - beta
57
- - 19
58
- version: 2.0.0.beta.19
59
- requirement: *id002
52
+ - 20
53
+ version: 2.0.0.beta.20
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: *id002
60
57
  description: RSpec's 'test double' framework, with support for stubbing and mocking
61
58
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
62
59
  executables: []
@@ -151,13 +148,7 @@ has_rdoc: true
151
148
  homepage: http://github.com/rspec/mocks
152
149
  licenses: []
153
150
 
154
- post_install_message: |
155
- **************************************************
156
-
157
- Thank you for installing rspec-mocks-2.0.0.beta.19
158
-
159
- **************************************************
160
-
151
+ post_install_message:
161
152
  rdoc_options:
162
153
  - --charset=UTF-8
163
154
  require_paths:
@@ -167,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
158
  requirements:
168
159
  - - ">="
169
160
  - !ruby/object:Gem::Version
170
- hash: 3
161
+ hash: -4186066668250905798
171
162
  segments:
172
163
  - 0
173
164
  version: "0"
@@ -176,7 +167,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
167
  requirements:
177
168
  - - ">"
178
169
  - !ruby/object:Gem::Version
179
- hash: 25
180
170
  segments:
181
171
  - 1
182
172
  - 3
@@ -188,7 +178,7 @@ rubyforge_project: rspec
188
178
  rubygems_version: 1.3.7
189
179
  signing_key:
190
180
  specification_version: 3
191
- summary: rspec-mocks-2.0.0.beta.19
181
+ summary: rspec-mocks-2.0.0.beta.20
192
182
  test_files:
193
183
  - spec/rspec/mocks/and_yield_spec.rb
194
184
  - spec/rspec/mocks/any_number_of_times_spec.rb