better_receive 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/better_receive.gemspec +1 -0
- data/lib/better_receive.rb +6 -6
- data/lib/better_receive/base.rb +15 -6
- data/lib/better_receive/mock.rb +7 -7
- data/lib/better_receive/stub.rb +9 -7
- data/lib/better_receive/version.rb +1 -1
- data/spec/lib/better_receive/mock_spec.rb +53 -31
- data/spec/lib/better_receive/stub_spec.rb +46 -40
- data/spec/lib/better_receive_spec.rb +8 -8
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0347a73bcd68f76e9652ea502dada80b1d6cdeb
|
4
|
+
data.tar.gz: 331cf56b59b2cf34ca9da2ed3a1e84a162a8b11a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e01b49c979194ddc5d5a936445219647b9e7f00cfda1288c544c65982b26b68847532adbca1e4aa54eb772a7b264f4620e98e0a850d4f377389a73eb353e50
|
7
|
+
data.tar.gz: ef8e3f26a9d94e4c81880d841e11030b502bab9eceb03d3465eae346811c1e680514391a8d056f4907019341bccd4f87e34c55775b40acc035c1735811dfc591
|
data/better_receive.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = BetterReceive::BETTER_VERSION
|
17
17
|
|
18
18
|
gem.add_dependency("rspec", "~> 2.14")
|
19
|
+
gem.add_dependency("rspec-core", "~> 2.14.6")
|
19
20
|
gem.add_development_dependency("rake", ">= 0")
|
20
21
|
gem.add_development_dependency("pry", ">= 0")
|
21
22
|
end
|
data/lib/better_receive.rb
CHANGED
@@ -4,16 +4,16 @@ require "better_receive/mock"
|
|
4
4
|
require "better_receive/stub"
|
5
5
|
|
6
6
|
module BetterReceive
|
7
|
-
def better_receive(
|
8
|
-
Mock.new(self
|
7
|
+
def better_receive(selector, options={}, &block)
|
8
|
+
Mock.new(self, selector, options, &block).assert
|
9
9
|
end
|
10
10
|
|
11
|
-
def better_not_receive(
|
12
|
-
Mock.new(self
|
11
|
+
def better_not_receive(selector, options={}, &block)
|
12
|
+
Mock.new(self, selector, options, &block).assert_negative
|
13
13
|
end
|
14
14
|
|
15
|
-
def better_stub(
|
16
|
-
Stub.new(self
|
15
|
+
def better_stub(selector, options={}, &block)
|
16
|
+
Stub.new(self, selector, options, &block).assert
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/lib/better_receive/base.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
module BetterReceive
|
2
2
|
class Base
|
3
3
|
|
4
|
-
def initialize(subject)
|
4
|
+
def initialize(subject, message, options={}, &block)
|
5
5
|
@subject = subject
|
6
|
+
@selector = message.is_a?(Hash) ? message : message.to_sym
|
7
|
+
@options = options
|
8
|
+
@block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(*args)
|
12
|
+
expectation.send(*args)
|
6
13
|
end
|
7
14
|
|
8
15
|
|
9
16
|
private
|
10
17
|
|
11
|
-
attr_reader :subject
|
18
|
+
attr_reader :subject, :selector, :options, :block, :expectation
|
12
19
|
|
13
20
|
def subject_is_any_instance?
|
14
21
|
defined?(RSpec::Mocks::AnyInstance) && subject.is_a?(RSpec::Mocks::AnyInstance::Recorder)
|
@@ -20,12 +27,12 @@ module BetterReceive
|
|
20
27
|
|
21
28
|
def any_instance_better_expect(selector, options, &block)
|
22
29
|
any_instance_should_respond_to selector
|
23
|
-
any_instance_add_expectation
|
30
|
+
any_instance_add_expectation(selector, &block)
|
24
31
|
end
|
25
32
|
|
26
33
|
def any_instance_better_not_expect(selector, options, &block)
|
27
34
|
any_instance_should_respond_to selector
|
28
|
-
any_instance_add_negative_expectation
|
35
|
+
any_instance_add_negative_expectation(selector, &block)
|
29
36
|
end
|
30
37
|
|
31
38
|
def any_instance_should_respond_to(selector)
|
@@ -38,13 +45,15 @@ module BetterReceive
|
|
38
45
|
def any_instance_add_expectation(selector, &block)
|
39
46
|
subject.send(:observe!, selector)
|
40
47
|
|
41
|
-
|
48
|
+
chain = expectation_chain(selector, &block)
|
49
|
+
@expectation = subject.message_chains.add(selector, chain)
|
42
50
|
end
|
43
51
|
|
44
52
|
def any_instance_add_negative_expectation(selector, &block)
|
45
53
|
subject.send(:observe!, selector)
|
46
54
|
|
47
|
-
|
55
|
+
chain = expectation_chain(selector, &block)
|
56
|
+
@expectation = subject.message_chains.add(selector, chain).never
|
48
57
|
end
|
49
58
|
|
50
59
|
end
|
data/lib/better_receive/mock.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module BetterReceive
|
2
2
|
class Mock < Base
|
3
3
|
|
4
|
-
def
|
5
|
-
selector = selector.to_sym
|
4
|
+
def assert
|
6
5
|
if subject_is_any_instance?
|
7
6
|
subject.instance_variable_set(:@expectation_set, true)
|
8
7
|
any_instance_better_expect(selector, options, &block)
|
@@ -10,10 +9,10 @@ module BetterReceive
|
|
10
9
|
subject.should respond_to selector
|
11
10
|
mock_subject_method(selector, options, &block)
|
12
11
|
end
|
12
|
+
self
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
selector = selector.to_sym
|
15
|
+
def assert_negative
|
17
16
|
if subject_is_any_instance?
|
18
17
|
subject.instance_variable_set(:@expectation_set, true)
|
19
18
|
any_instance_better_not_expect(selector, options, &block)
|
@@ -21,6 +20,7 @@ module BetterReceive
|
|
21
20
|
subject.should respond_to selector
|
22
21
|
negative_mock_subject_method(selector, options, &block)
|
23
22
|
end
|
23
|
+
self
|
24
24
|
end
|
25
25
|
|
26
26
|
|
@@ -32,16 +32,16 @@ module BetterReceive
|
|
32
32
|
|
33
33
|
def mock_subject_method(selector, options, &block)
|
34
34
|
location = options[:expected_from] || caller(1)[2]
|
35
|
-
subject_mock_proxy.add_message_expectation(location, selector, options, &block)
|
35
|
+
@expectation = subject_mock_proxy.add_message_expectation(location, selector, options, &block)
|
36
36
|
end
|
37
37
|
|
38
38
|
def negative_mock_subject_method(selector, options, &block)
|
39
39
|
location = options[:expected_from] || caller(1)[2]
|
40
|
-
subject_mock_proxy.add_message_expectation(location, selector, options, &block).never
|
40
|
+
@expectation = subject_mock_proxy.add_message_expectation(location, selector, options, &block).never
|
41
41
|
end
|
42
42
|
|
43
43
|
def expectation_chain(*args)
|
44
|
-
RSpec::Mocks::AnyInstance::PositiveExpectationChain.new(*args)
|
44
|
+
RSpec::Mocks::AnyInstance::PositiveExpectationChain.new(subject, *args)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/better_receive/stub.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module BetterReceive
|
2
2
|
class Stub < Base
|
3
3
|
|
4
|
-
def
|
5
|
-
if
|
6
|
-
|
7
|
-
better_stub_method(
|
4
|
+
def assert
|
5
|
+
if selector.is_a?(Hash)
|
6
|
+
selector.each do |single_selector, value|
|
7
|
+
better_stub_method(single_selector.to_sym, options, &block)
|
8
|
+
.and_return(value)
|
8
9
|
end
|
9
10
|
else
|
10
|
-
better_stub_method(
|
11
|
+
better_stub_method(selector, options, &block)
|
11
12
|
end
|
13
|
+
self
|
12
14
|
end
|
13
15
|
|
14
16
|
|
@@ -20,12 +22,12 @@ module BetterReceive
|
|
20
22
|
any_instance_better_expect(selector, options, &block)
|
21
23
|
else
|
22
24
|
subject.should respond_to selector
|
23
|
-
subject.stub(selector, options, &block)
|
25
|
+
@expectation = subject.stub(selector, options, &block)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def expectation_chain(*args)
|
28
|
-
RSpec::Mocks::AnyInstance::StubChain.new(*args)
|
30
|
+
RSpec::Mocks::AnyInstance::StubChain.new(subject, *args)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -6,34 +6,39 @@ describe BetterReceive::Mock do
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
describe "#
|
9
|
+
describe "#assert" do
|
10
10
|
let(:foo) { Foo.new }
|
11
|
-
let(:
|
11
|
+
let(:selector) { :bar }
|
12
|
+
let(:br_mock) { BetterReceive::Mock.new(foo, selector) }
|
12
13
|
|
13
14
|
it "determines whether an object responds to a method" do
|
14
15
|
foo.should_receive(:respond_to?).with(:bar).and_return(true)
|
15
16
|
|
16
|
-
br_mock.
|
17
|
+
br_mock.assert
|
17
18
|
|
18
19
|
foo.bar
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
context "when the method is not defined" do
|
23
|
+
let(:selector) { :bar_baz }
|
24
|
+
|
25
|
+
it "raises an error if the method is not defined" do
|
26
|
+
expect {
|
27
|
+
br_mock.assert
|
28
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError) { |error|
|
29
|
+
error.message.should =~ /to respond to :bar_baz/
|
30
|
+
}
|
31
|
+
end
|
27
32
|
end
|
28
33
|
|
29
34
|
it "returns an rspec message expectation" do
|
30
|
-
foo.better_receive(:bar).should be_a
|
35
|
+
foo.better_receive(:bar).should be_a BetterReceive::Mock
|
31
36
|
|
32
37
|
foo.bar
|
33
38
|
end
|
34
39
|
|
35
40
|
it "responds to additional matchers(:with, :once...)" do
|
36
|
-
br_mock.
|
41
|
+
br_mock.assert.with('wibble')
|
37
42
|
|
38
43
|
foo.bar('wibble')
|
39
44
|
end
|
@@ -42,9 +47,10 @@ describe BetterReceive::Mock do
|
|
42
47
|
let(:selector) { :bar }
|
43
48
|
let(:options) { {passed: true} }
|
44
49
|
let(:block_param) { Proc.new {} }
|
50
|
+
let(:br_mock) { BetterReceive::Mock.new(foo, selector, options, &block_param) }
|
45
51
|
|
46
52
|
before do
|
47
|
-
br_mock.
|
53
|
+
br_mock.assert
|
48
54
|
|
49
55
|
@expectation = RSpec::Mocks.proxy_for(foo).send(:method_doubles)[0][:expectations][0]
|
50
56
|
end
|
@@ -69,13 +75,14 @@ describe BetterReceive::Mock do
|
|
69
75
|
end
|
70
76
|
|
71
77
|
context "on .any_instance" do
|
72
|
-
let(:
|
78
|
+
let(:selector) { :bar }
|
79
|
+
let(:br_mock) { BetterReceive::Mock.new(Foo.any_instance, selector) }
|
73
80
|
|
74
81
|
context "when the method is defined" do
|
75
82
|
context "and the method is called" do
|
76
83
|
it 'does not raise an error' do
|
77
84
|
expect {
|
78
|
-
br_mock.
|
85
|
+
br_mock.assert
|
79
86
|
foo.bar
|
80
87
|
}.to_not raise_error
|
81
88
|
end
|
@@ -84,19 +91,27 @@ describe BetterReceive::Mock do
|
|
84
91
|
context 'and the method is not called' do
|
85
92
|
it 'does raise an error' do
|
86
93
|
expect {
|
87
|
-
br_mock.
|
94
|
+
br_mock.assert
|
88
95
|
RSpec::Mocks::space.verify_all
|
89
96
|
}.to raise_error(RSpec::Mocks::MockExpectationError) { |error|
|
90
97
|
error.message.should == "Exactly one instance should have received the following message(s) but didn't: bar"
|
91
98
|
}
|
92
99
|
end
|
93
100
|
end
|
101
|
+
|
102
|
+
it 'responds to additional matchers' do
|
103
|
+
br_mock.assert.with(1).and_return(2)
|
104
|
+
|
105
|
+
foo.bar(1).should == 2
|
106
|
+
end
|
94
107
|
end
|
95
108
|
|
96
109
|
context 'when the method is not defined' do
|
110
|
+
let(:selector) { :baz }
|
111
|
+
|
97
112
|
it 'raises an error' do
|
98
113
|
expect {
|
99
|
-
br_mock.
|
114
|
+
br_mock.assert
|
100
115
|
}.to raise_error { |error|
|
101
116
|
error.message.should == "Expected instances of Foo to respond to :baz"
|
102
117
|
}
|
@@ -105,20 +120,24 @@ describe BetterReceive::Mock do
|
|
105
120
|
end
|
106
121
|
end
|
107
122
|
|
108
|
-
describe "#
|
123
|
+
describe "#assert_negative" do
|
109
124
|
let(:foo) { Foo.new }
|
110
|
-
let(:
|
125
|
+
let(:selector) { :bar }
|
126
|
+
let(:br_mock) { BetterReceive::Mock.new(foo, selector) }
|
111
127
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
128
|
+
context "when the method is not defined" do
|
129
|
+
let(:selector) { :bar_baz }
|
130
|
+
it "raises an error" do
|
131
|
+
expect {
|
132
|
+
br_mock.assert_negative
|
133
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError) { |error|
|
134
|
+
error.message.should =~ /to respond to :bar_baz/
|
135
|
+
}
|
136
|
+
end
|
118
137
|
end
|
119
138
|
|
120
139
|
it "returns an rspec message expectation" do
|
121
|
-
br_mock.
|
140
|
+
br_mock.assert_negative.should be_a BetterReceive::Mock
|
122
141
|
|
123
142
|
expect {
|
124
143
|
foo.bar
|
@@ -128,7 +147,7 @@ describe BetterReceive::Mock do
|
|
128
147
|
end
|
129
148
|
|
130
149
|
it "responds to additional matchers(:with, :once...)" do
|
131
|
-
br_mock.
|
150
|
+
br_mock.assert_negative.with('wibble')
|
132
151
|
expect {
|
133
152
|
foo.bar('wibble')
|
134
153
|
}.to raise_error(RSpec::Mocks::MockExpectationError) { |error|
|
@@ -140,9 +159,10 @@ describe BetterReceive::Mock do
|
|
140
159
|
let(:selector) { :bar }
|
141
160
|
let(:options) { {passed: true} }
|
142
161
|
let(:block_param) { Proc.new {} }
|
162
|
+
let(:br_mock) { BetterReceive::Mock.new(foo, selector, options, &block_param) }
|
143
163
|
|
144
164
|
before do
|
145
|
-
br_mock.
|
165
|
+
br_mock.assert_negative
|
146
166
|
|
147
167
|
@expectation = RSpec::Mocks.proxy_for(foo).send(:method_doubles)[0][:expectations][0]
|
148
168
|
end
|
@@ -163,11 +183,12 @@ describe BetterReceive::Mock do
|
|
163
183
|
end
|
164
184
|
|
165
185
|
context "on .any_instance" do
|
166
|
-
let(:
|
186
|
+
let(:selector) { :bar }
|
187
|
+
let(:br_mock) { BetterReceive::Mock.new(Foo.any_instance, selector) }
|
167
188
|
|
168
189
|
it 'raises when called' do
|
169
190
|
expect {
|
170
|
-
br_mock.
|
191
|
+
br_mock.assert_negative
|
171
192
|
foo.bar
|
172
193
|
}.to raise_error(RSpec::Mocks::MockExpectationError) { |error|
|
173
194
|
error.message.should include "received: 1 time"
|
@@ -176,15 +197,16 @@ describe BetterReceive::Mock do
|
|
176
197
|
|
177
198
|
it 'does not raise an error if not called' do
|
178
199
|
expect {
|
179
|
-
br_mock.
|
200
|
+
br_mock.assert_negative
|
180
201
|
RSpec::Mocks::space.verify_all
|
181
202
|
}.to_not raise_error
|
182
203
|
end
|
183
204
|
|
184
205
|
context 'when the method is not defined' do
|
206
|
+
let(:selector) { :baz }
|
185
207
|
it 'raises an error' do
|
186
208
|
expect {
|
187
|
-
br_mock.
|
209
|
+
br_mock.assert_negative
|
188
210
|
}.to raise_error { |error|
|
189
211
|
error.message.should == "Expected instances of Foo to respond to :baz"
|
190
212
|
}
|
@@ -6,46 +6,45 @@ describe BetterReceive::Stub do
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
describe "#
|
9
|
+
describe "#assert" do
|
10
10
|
let(:foo) { Foo.new }
|
11
|
-
let(:
|
11
|
+
let(:selector) { :bar }
|
12
|
+
let(:br_stub) { BetterReceive::Stub.new(foo, selector) }
|
12
13
|
|
13
14
|
context "when passed a single selector" do
|
14
15
|
it "determines whether an object responds to a method" do
|
15
16
|
foo.should_receive(:respond_to?).with(:bar).and_return(true)
|
16
17
|
|
17
|
-
br_stub.
|
18
|
+
br_stub.assert
|
18
19
|
|
19
20
|
foo.bar
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
context "when the method is not defined" do
|
24
|
+
let(:selector) { :bar_baz }
|
25
|
+
it "raises an error" do
|
26
|
+
expect {
|
27
|
+
br_stub.assert
|
28
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError) { |error|
|
29
|
+
error.message.should =~ /to respond to :bar_baz/
|
30
|
+
}
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
it "returns an rspec message expectation(responds to additional matchers ('with', 'once'...))" do
|
31
|
-
br_stub.
|
32
|
-
|
33
|
-
br_stub.assert_with(:bar).with('wibble')
|
34
|
-
end
|
35
|
+
br_stub.assert.should be_a BetterReceive::Stub
|
35
36
|
|
36
|
-
|
37
|
-
br_stub.assert_with(:bar) { :baz }
|
38
|
-
|
39
|
-
foo.bar.should == :baz
|
37
|
+
br_stub.assert.with('wibble')
|
40
38
|
end
|
41
39
|
|
42
40
|
context "when passing arguments" do
|
43
41
|
let(:selector) { :bar }
|
44
42
|
let(:options) { {passed: true} }
|
45
|
-
let(:block_param) { Proc.new {} }
|
43
|
+
let(:block_param) { Proc.new { "returned value" } }
|
44
|
+
let(:br_stub) { BetterReceive::Stub.new(foo, selector, options, &block_param) }
|
46
45
|
|
47
46
|
before do
|
48
|
-
br_stub.
|
47
|
+
br_stub.assert
|
49
48
|
|
50
49
|
@stub = RSpec::Mocks.proxy_for(foo).send(:method_doubles)[0][:stubs][0]
|
51
50
|
end
|
@@ -56,6 +55,12 @@ describe BetterReceive::Stub do
|
|
56
55
|
@stub.send(:error_generator).opts.should == options
|
57
56
|
end
|
58
57
|
|
58
|
+
it "returns the value passed in the block" do
|
59
|
+
br_stub.assert
|
60
|
+
|
61
|
+
foo.bar.should == block_param.call
|
62
|
+
end
|
63
|
+
|
59
64
|
context "when the selector is a string" do
|
60
65
|
let(:selector) { "bar" }
|
61
66
|
|
@@ -71,31 +76,29 @@ describe BetterReceive::Stub do
|
|
71
76
|
def extra; end
|
72
77
|
end
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
params = {bar: '1', extra: '2'}
|
79
|
+
it "determines whether an object responds to a method" do
|
80
|
+
br_stub = BetterReceive::Stub.new(foo, {bar: '1', extra: '2'})
|
77
81
|
|
78
|
-
|
79
|
-
|
82
|
+
foo.should_receive(:respond_to?).with(:bar).and_return(true)
|
83
|
+
foo.should_receive(:respond_to?).with(:extra).and_return(true)
|
80
84
|
|
81
|
-
|
82
|
-
|
85
|
+
br_stub.assert
|
86
|
+
end
|
83
87
|
|
84
|
-
|
85
|
-
|
88
|
+
it "raises an error if the method is not defined" do
|
89
|
+
br_stub = BetterReceive::Stub.new(foo, {bar: '1', baz: '2'})
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
91
|
+
expect{
|
92
|
+
br_stub.assert
|
93
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError) { |error|
|
94
|
+
error.message.should =~ /to respond to :baz/
|
95
|
+
}
|
93
96
|
end
|
94
97
|
|
95
98
|
context "and stubbing" do
|
96
99
|
it 'stubs out each method' do
|
97
|
-
|
98
|
-
br_stub.
|
100
|
+
br_stub = BetterReceive::Stub.new(foo, {bar: '1', extra: '2'})
|
101
|
+
br_stub.assert
|
99
102
|
|
100
103
|
foo.bar.should == '1'
|
101
104
|
foo.extra.should == '2'
|
@@ -104,24 +107,27 @@ describe BetterReceive::Stub do
|
|
104
107
|
end
|
105
108
|
|
106
109
|
context "on .any_instance" do
|
107
|
-
let(:
|
110
|
+
let(:selector) { :bar }
|
111
|
+
let(:br_stub) { BetterReceive::Stub.new(Foo.any_instance, selector) }
|
108
112
|
|
109
113
|
context "when the method is defined" do
|
110
114
|
it 'stubs the method out' do
|
111
|
-
br_stub.
|
115
|
+
br_stub.assert.and_return(:whatever)
|
112
116
|
|
113
117
|
foo.bar.should == :whatever
|
114
118
|
end
|
115
119
|
|
116
120
|
it "does not blow up if the method is not called" do
|
117
|
-
br_stub.
|
121
|
+
br_stub.assert
|
118
122
|
end
|
119
123
|
end
|
120
124
|
|
121
125
|
context 'when the method is not defined' do
|
126
|
+
let(:selector) { :baz }
|
127
|
+
|
122
128
|
it 'raises an error' do
|
123
129
|
expect {
|
124
|
-
br_stub.
|
130
|
+
br_stub.assert
|
125
131
|
}.to raise_error { |error|
|
126
132
|
error.message.should == "Expected instances of Foo to respond to :baz"
|
127
133
|
}
|
@@ -10,21 +10,21 @@ describe BetterReceive do
|
|
10
10
|
let(:br_instance) { double(BetterReceive::Mock).as_null_object }
|
11
11
|
|
12
12
|
it "passes the object being mocked into a new BetterReceive::Mock instance" do
|
13
|
-
BetterReceive::Mock.should_receive(:new).with(foo).and_return(br_instance)
|
13
|
+
BetterReceive::Mock.should_receive(:new).with(foo, :bar, {}).and_return(br_instance)
|
14
14
|
|
15
15
|
foo.better_receive(:bar)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "checks that the object responds to the method and that the method is called" do
|
19
|
-
BetterReceive::Mock.stub(:new).with(foo).and_return(br_instance)
|
19
|
+
BetterReceive::Mock.stub(:new).with(foo, :bar, {}).and_return(br_instance)
|
20
20
|
|
21
|
-
br_instance.should_receive(:
|
21
|
+
br_instance.should_receive(:assert)
|
22
22
|
|
23
23
|
foo.better_receive(:bar)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns an RSpec expectation object" do
|
27
|
-
foo.better_receive(:bar).should be_a
|
27
|
+
foo.better_receive(:bar).should be_a BetterReceive::Mock
|
28
28
|
|
29
29
|
foo.bar
|
30
30
|
|
@@ -46,21 +46,21 @@ describe BetterReceive do
|
|
46
46
|
let(:br_instance) { double(BetterReceive::Stub).as_null_object }
|
47
47
|
|
48
48
|
it "passes the object being stubbed into a new BetterReceive::Stub instance" do
|
49
|
-
BetterReceive::Stub.should_receive(:new).with(foo).and_return(br_instance)
|
49
|
+
BetterReceive::Stub.should_receive(:new).with(foo, :bar, {}).and_return(br_instance)
|
50
50
|
|
51
51
|
foo.better_stub(:bar)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "checks that the object responds to the method and that the method is called" do
|
55
|
-
BetterReceive::Stub.stub(:new).with(foo).and_return(br_instance)
|
55
|
+
BetterReceive::Stub.stub(:new).with(foo, :bar, {}).and_return(br_instance)
|
56
56
|
|
57
|
-
br_instance.should_receive(:
|
57
|
+
br_instance.should_receive(:assert)
|
58
58
|
|
59
59
|
foo.better_stub(:bar)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "returns an RSpec expectation object" do
|
63
|
-
foo.better_stub(:bar).should be_a
|
63
|
+
foo.better_stub(:bar).should be_a BetterReceive::Stub
|
64
64
|
|
65
65
|
foo.bar
|
66
66
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_receive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Ellis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.14'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec-core
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.14.6
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.14.6
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: rake
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
111
|
version: '0'
|
98
112
|
requirements: []
|
99
113
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.0.
|
114
|
+
rubygems_version: 2.0.3
|
101
115
|
signing_key:
|
102
116
|
specification_version: 4
|
103
117
|
summary: A more assertive mock.
|