rspec 1.2.4 → 1.2.5
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.
- data.tar.gz.sig +0 -0
- data/History.rdoc +59 -32
- data/Manifest.txt +6 -0
- data/Rakefile +2 -2
- data/examples/passing/options_example.rb +31 -0
- data/examples/passing/options_formatter.rb +20 -0
- data/features/expectations/expect_change.feature +65 -0
- data/features/expectations/expect_error.feature +44 -0
- data/lib/spec/example/example_group_factory.rb +4 -2
- data/lib/spec/example/example_group_methods.rb +5 -1
- data/lib/spec/example/example_group_proxy.rb +8 -0
- data/lib/spec/example/example_matcher.rb +2 -3
- data/lib/spec/example/example_methods.rb +14 -1
- data/lib/spec/example/example_proxy.rb +3 -4
- data/lib/spec/example/subject.rb +7 -7
- data/lib/spec/interop/test.rb +2 -1
- data/lib/spec/matchers/be_close.rb +5 -5
- data/lib/spec/matchers/be_instance_of.rb +2 -2
- data/lib/spec/matchers/be_kind_of.rb +2 -2
- data/lib/spec/matchers/compatibility.rb +2 -2
- data/lib/spec/matchers/eql.rb +4 -4
- data/lib/spec/matchers/equal.rb +18 -8
- data/lib/spec/matchers/extensions/instance_exec.rb +1 -3
- data/lib/spec/matchers/include.rb +4 -4
- data/lib/spec/matchers/match.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +3 -2
- data/lib/spec/mocks/methods.rb +9 -0
- data/lib/spec/mocks/mock.rb +34 -24
- data/lib/spec/mocks/proxy.rb +1 -0
- data/lib/spec/mocks/spec_methods.rb +5 -5
- data/lib/spec/runner.rb +1 -2
- data/lib/spec/runner/configuration.rb +0 -0
- data/lib/spec/runner/drb_command_line.rb +2 -0
- data/lib/spec/runner/formatter/base_text_formatter.rb +1 -1
- data/lib/spec/runner/formatter/no_op_method_missing.rb +1 -1
- data/lib/spec/version.rb +1 -1
- data/spec/spec/example/example_group_proxy_spec.rb +24 -0
- data/spec/spec/example/example_methods_spec.rb +12 -0
- data/spec/spec/example/predicate_matcher_spec.rb +0 -0
- data/spec/spec/example/subject_spec.rb +16 -6
- data/spec/spec/matchers/change_spec.rb +85 -85
- data/spec/spec/matchers/compatibility_spec.rb +16 -22
- data/spec/spec/matchers/equal_spec.rb +33 -9
- data/spec/spec/matchers/have_spec.rb +1 -8
- data/spec/spec/mocks/mock_ordering_spec.rb +10 -0
- data/spec/spec/mocks/mock_spec.rb +106 -93
- data/spec/spec/mocks/stub_chain_spec.rb +27 -0
- data/spec/spec/mocks/stub_spec.rb +9 -5
- data/spec/spec/runner/configuration_spec.rb +0 -0
- data/spec/spec/runner/drb_command_line_spec.rb +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +31 -46
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +25 -28
- data/spec/spec/runner/formatter/html_formatter_spec.rb +3 -19
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +3 -18
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +4 -28
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +31 -46
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +7 -10
- data/spec/spec/runner/reporter_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/support/macros.rb +29 -0
- metadata +36 -8
- metadata.gz.sig +1 -0
@@ -20,10 +20,10 @@ module Spec
|
|
20
20
|
# stub_person = stub("thing", :name => "Joe", :email => "joe@domain.com")
|
21
21
|
# stub_person.name => "Joe"
|
22
22
|
# stub_person.email => "joe@domain.com"
|
23
|
-
def mock(
|
24
|
-
Spec::Mocks::Mock.new(
|
23
|
+
def mock(*args)
|
24
|
+
Spec::Mocks::Mock.new(*args)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
alias :stub :mock
|
28
28
|
|
29
29
|
# DEPRECATED - use mock('name').as_null_object instead
|
@@ -41,10 +41,10 @@ or stub('#{name}').as_null_object instead.
|
|
41
41
|
WARNING
|
42
42
|
mock(name, :null_object => true)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
# Disables warning messages about expectations being set on nil.
|
46
46
|
#
|
47
|
-
# By default warning messages are issued when expectations are set on nil. This is to
|
47
|
+
# By default warning messages are issued when expectations are set on nil. This is to
|
48
48
|
# prevent false-positives and to catch potential bugs early on.
|
49
49
|
def allow_message_expectations_on_nil
|
50
50
|
Proxy.allow_message_expectations_on_nil
|
data/lib/spec/runner.rb
CHANGED
File without changes
|
@@ -12,8 +12,10 @@ module Spec
|
|
12
12
|
DRb.start_service("druby://localhost:0")
|
13
13
|
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:8989")
|
14
14
|
spec_server.run(options.argv, options.error_stream, options.output_stream)
|
15
|
+
true
|
15
16
|
rescue DRb::DRbConnError
|
16
17
|
options.error_stream.puts "No server is running"
|
18
|
+
false
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -28,7 +28,7 @@ module Spec
|
|
28
28
|
@example_group = example_group_proxy
|
29
29
|
end
|
30
30
|
|
31
|
-
def example_pending(example, message,
|
31
|
+
def example_pending(example, message, deprecated_pending_location=nil)
|
32
32
|
@pending_examples << ["#{@example_group.description} #{example.description}", message, example.location]
|
33
33
|
end
|
34
34
|
|
data/lib/spec/version.rb
CHANGED
@@ -78,6 +78,30 @@ module Spec
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
describe "#options" do
|
82
|
+
it "provides the options passed to the example group declaration" do
|
83
|
+
group.stub!(:options => {:a => 'b'})
|
84
|
+
proxy.options.should == {:a => 'b'}
|
85
|
+
end
|
86
|
+
|
87
|
+
it "excludes :location" do
|
88
|
+
group.stub!(:options => {:location => 'b'})
|
89
|
+
proxy.options.should == {}
|
90
|
+
end
|
91
|
+
|
92
|
+
it "excludes :scope" do
|
93
|
+
group.stub!(:options => {:scope => 'b'})
|
94
|
+
proxy.options.should == {}
|
95
|
+
end
|
96
|
+
|
97
|
+
it "preserves the original hash" do
|
98
|
+
hash = {:a => 'b', :location => 'here', :scope => 'tiny'}
|
99
|
+
group.stub!(:options => hash)
|
100
|
+
proxy.options.should == {:a => 'b'}
|
101
|
+
hash.should == {:a => 'b', :location => 'here', :scope => 'tiny'}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
81
105
|
end
|
82
106
|
end
|
83
107
|
end
|
@@ -117,6 +117,18 @@ module Spec
|
|
117
117
|
end.should raise_error(/No description supplied for example declared on this backtrace/)
|
118
118
|
end
|
119
119
|
end
|
120
|
+
|
121
|
+
describe "#expect" do
|
122
|
+
it "aliases #should with #to on the proc" do
|
123
|
+
a = 3
|
124
|
+
expect { a += 1 }.to change{a}.from(3).to(4)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "aliases #should_not with #to_not on the proc" do
|
128
|
+
a = 3
|
129
|
+
expect { nil }.to_not change{a}
|
130
|
+
end
|
131
|
+
end
|
120
132
|
|
121
133
|
end
|
122
134
|
end
|
File without changes
|
@@ -48,8 +48,8 @@ module Spec
|
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "defined in a top level group" do
|
51
|
-
|
52
|
-
|
51
|
+
before(:each) do
|
52
|
+
@group = Class.new do
|
53
53
|
extend Spec::Example::Subject::ExampleGroupMethods
|
54
54
|
include Spec::Example::Subject::ExampleMethods
|
55
55
|
class << self
|
@@ -65,11 +65,21 @@ module Spec
|
|
65
65
|
[1,2,3]
|
66
66
|
}
|
67
67
|
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "is available in a nested group (subclass)" do
|
71
|
+
nested_group = Class.new(@group)
|
68
72
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
example = nested_group.new
|
74
|
+
example.subject.should == [1,2,3]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "is available in a doubly nested group (subclass)" do
|
78
|
+
nested_group = Class.new(@group)
|
79
|
+
doubly_nested_group = Class.new(nested_group)
|
80
|
+
|
81
|
+
example = doubly_nested_group.new
|
82
|
+
example.subject.should == [1,2,3]
|
73
83
|
end
|
74
84
|
end
|
75
85
|
end
|
@@ -12,13 +12,13 @@ describe "should change(actual, message)" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should pass when actual is modified by the block" do
|
15
|
-
|
15
|
+
expect {@instance.some_value = 6}.to change(@instance, :some_value)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should fail when actual is not modified by the block" do
|
19
|
-
|
20
|
-
|
21
|
-
end.
|
19
|
+
expect do
|
20
|
+
expect {}.to change(@instance, :some_value)
|
21
|
+
end.to fail_with("some_value should have changed, but is still 5")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "provides a #description" do
|
@@ -33,13 +33,13 @@ describe "should_not change(actual, message)" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should pass when actual is not modified by the block" do
|
36
|
-
|
36
|
+
expect { }.to_not change(@instance, :some_value)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should fail when actual is not modified by the block" do
|
40
|
-
|
41
|
-
|
42
|
-
end.
|
40
|
+
expect do
|
41
|
+
expect {@instance.some_value = 6}.to_not change(@instance, :some_value)
|
42
|
+
end.to fail_with("some_value should not have changed, but did change from 5 to 6")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -50,19 +50,19 @@ describe "should change { block }" do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should pass when actual is modified by the block" do
|
53
|
-
|
53
|
+
expect {@instance.some_value = 6}.to change { @instance.some_value }
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should fail when actual is not modified by the block" do
|
57
|
-
|
58
|
-
|
59
|
-
end.
|
57
|
+
expect do
|
58
|
+
expect {}.to change{ @instance.some_value }
|
59
|
+
end.to fail_with("result should have changed, but is still 5")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should warn if passed a block using do/end instead of {}" do
|
63
|
-
|
64
|
-
|
65
|
-
end.
|
63
|
+
expect do
|
64
|
+
expect {}.to change do; end
|
65
|
+
end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "provides a #description" do
|
@@ -77,19 +77,19 @@ describe "should_not change { block }" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should pass when actual is modified by the block" do
|
80
|
-
|
80
|
+
expect {}.to_not change{ @instance.some_value }
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should fail when actual is not modified by the block" do
|
84
|
-
|
85
|
-
|
86
|
-
end.
|
84
|
+
expect do
|
85
|
+
expect {@instance.some_value = 6}.to_not change { @instance.some_value }
|
86
|
+
end.to fail_with("result should not have changed, but did change from 5 to 6")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should warn if passed a block using do/end instead of {}" do
|
90
|
-
|
91
|
-
|
92
|
-
end.
|
90
|
+
expect do
|
91
|
+
expect {}.to_not change do; end
|
92
|
+
end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -100,19 +100,19 @@ describe "should change(actual, message).by(expected)" do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should pass when attribute is changed by expected amount" do
|
103
|
-
|
103
|
+
expect { @instance.some_value += 1 }.to change(@instance, :some_value).by(1)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should fail when the attribute is changed by unexpected amount" do
|
107
|
-
|
108
|
-
|
109
|
-
end.
|
107
|
+
expect do
|
108
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by(1)
|
109
|
+
end.to fail_with("some_value should have been changed by 1, but was changed by 2")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
|
113
|
-
|
114
|
-
|
115
|
-
end.
|
113
|
+
expect do
|
114
|
+
expect { @instance.some_value -= 1 }.to change(@instance, :some_value).by(1)
|
115
|
+
end.to fail_with("some_value should have been changed by 1, but was changed by -1")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -123,19 +123,19 @@ describe "should change{ block }.by(expected)" do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should pass when attribute is changed by expected amount" do
|
126
|
-
|
126
|
+
expect { @instance.some_value += 1 }.to change{@instance.some_value}.by(1)
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should fail when the attribute is changed by unexpected amount" do
|
130
|
-
|
131
|
-
|
132
|
-
end.
|
130
|
+
expect do
|
131
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by(1)
|
132
|
+
end.to fail_with("result should have been changed by 1, but was changed by 2")
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
|
136
|
-
|
137
|
-
|
138
|
-
end.
|
136
|
+
expect do
|
137
|
+
expect { @instance.some_value -= 1 }.to change{@instance.some_value}.by(1)
|
138
|
+
end.to fail_with("result should have been changed by 1, but was changed by -1")
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -146,17 +146,17 @@ describe "should change(actual, message).by_at_least(expected)" do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should pass when attribute is changed by greater than the expected amount" do
|
149
|
-
|
149
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(1)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should pass when attribute is changed by the expected amount" do
|
153
|
-
|
153
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(2)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should fail when the attribute is changed by less than the expected amount" do
|
157
|
-
|
158
|
-
|
159
|
-
end.
|
157
|
+
expect do
|
158
|
+
expect { @instance.some_value += 1 }.to change(@instance, :some_value).by_at_least(2)
|
159
|
+
end.to fail_with("some_value should have been changed by at least 2, but was changed by 1")
|
160
160
|
end
|
161
161
|
|
162
162
|
end
|
@@ -168,17 +168,17 @@ describe "should change{ block }.by_at_least(expected)" do
|
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should pass when attribute is changed by greater than expected amount" do
|
171
|
-
|
171
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(1)
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should pass when attribute is changed by the expected amount" do
|
175
|
-
|
175
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(2)
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should fail when the attribute is changed by less than the unexpected amount" do
|
179
|
-
|
180
|
-
|
181
|
-
end.
|
179
|
+
expect do
|
180
|
+
expect { @instance.some_value += 1 }.to change{@instance.some_value}.by_at_least(2)
|
181
|
+
end.to fail_with("result should have been changed by at least 2, but was changed by 1")
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -190,17 +190,17 @@ describe "should change(actual, message).by_at_most(expected)" do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should pass when attribute is changed by less than the expected amount" do
|
193
|
-
|
193
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(3)
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should pass when attribute is changed by the expected amount" do
|
197
|
-
|
197
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(2)
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should fail when the attribute is changed by greater than the expected amount" do
|
201
|
-
|
202
|
-
|
203
|
-
end.
|
201
|
+
expect do
|
202
|
+
expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(1)
|
203
|
+
end.to fail_with("some_value should have been changed by at most 1, but was changed by 2")
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
@@ -212,17 +212,17 @@ describe "should change{ block }.by_at_most(expected)" do
|
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should pass when attribute is changed by less than expected amount" do
|
215
|
-
|
215
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(3)
|
216
216
|
end
|
217
217
|
|
218
218
|
it "should pass when attribute is changed by the expected amount" do
|
219
|
-
|
219
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(2)
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should fail when the attribute is changed by greater than the unexpected amount" do
|
223
|
-
|
224
|
-
|
225
|
-
end.
|
223
|
+
expect do
|
224
|
+
expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(1)
|
225
|
+
end.to fail_with("result should have been changed by at most 1, but was changed by 2")
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -233,13 +233,13 @@ describe "should change(actual, message).from(old)" do
|
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should pass when attribute is == to expected value before executing block" do
|
236
|
-
|
236
|
+
expect { @instance.some_value = "astring" }.to change(@instance, :some_value).from("string")
|
237
237
|
end
|
238
238
|
|
239
239
|
it "should fail when attribute is not == to expected value before executing block" do
|
240
|
-
|
241
|
-
|
242
|
-
end.
|
240
|
+
expect do
|
241
|
+
expect { @instance.some_value = "knot" }.to change(@instance, :some_value).from("cat")
|
242
|
+
end.to fail_with("some_value should have initially been \"cat\", but was \"string\"")
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -250,13 +250,13 @@ describe "should change{ block }.from(old)" do
|
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should pass when attribute is == to expected value before executing block" do
|
253
|
-
|
253
|
+
expect { @instance.some_value = "astring" }.to change{@instance.some_value}.from("string")
|
254
254
|
end
|
255
255
|
|
256
256
|
it "should fail when attribute is not == to expected value before executing block" do
|
257
|
-
|
258
|
-
|
259
|
-
end.
|
257
|
+
expect do
|
258
|
+
expect { @instance.some_value = "knot" }.to change{@instance.some_value}.from("cat")
|
259
|
+
end.to fail_with("result should have initially been \"cat\", but was \"string\"")
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
@@ -267,13 +267,13 @@ describe "should change(actual, message).to(new)" do
|
|
267
267
|
end
|
268
268
|
|
269
269
|
it "should pass when attribute is == to expected value after executing block" do
|
270
|
-
|
270
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat")
|
271
271
|
end
|
272
272
|
|
273
273
|
it "should fail when attribute is not == to expected value after executing block" do
|
274
|
-
|
275
|
-
|
276
|
-
end.
|
274
|
+
expect do
|
275
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog")
|
276
|
+
end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
@@ -284,13 +284,13 @@ describe "should change{ block }.to(new)" do
|
|
284
284
|
end
|
285
285
|
|
286
286
|
it "should pass when attribute is == to expected value after executing block" do
|
287
|
-
|
287
|
+
expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat")
|
288
288
|
end
|
289
289
|
|
290
290
|
it "should fail when attribute is not == to expected value after executing block" do
|
291
|
-
|
292
|
-
|
293
|
-
end.
|
291
|
+
expect do
|
292
|
+
expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("dog")
|
293
|
+
end.to fail_with("result should have been changed to \"dog\", but is now \"cat\"")
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
@@ -301,23 +301,23 @@ describe "should change(actual, message).from(old).to(new)" do
|
|
301
301
|
end
|
302
302
|
|
303
303
|
it "should pass when #to comes before #from" do
|
304
|
-
|
304
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat").from("string")
|
305
305
|
end
|
306
306
|
|
307
307
|
it "should pass when #from comes before #to" do
|
308
|
-
|
308
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("cat")
|
309
309
|
end
|
310
310
|
|
311
311
|
it "should show the correct messaging when #after and #to are different" do
|
312
|
-
|
313
|
-
|
314
|
-
end.
|
312
|
+
expect do
|
313
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog")
|
314
|
+
end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
|
315
315
|
end
|
316
316
|
|
317
317
|
it "should show the correct messaging when #before and #from are different" do
|
318
|
-
|
319
|
-
|
320
|
-
end.
|
318
|
+
expect do
|
319
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("not_string").to("cat")
|
320
|
+
end.to fail_with("some_value should have initially been \"not_string\", but was \"string\"")
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
@@ -328,11 +328,11 @@ describe "should change{ block }.from(old).to(new)" do
|
|
328
328
|
end
|
329
329
|
|
330
330
|
it "should pass when #to comes before #from" do
|
331
|
-
|
331
|
+
expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat").from("string")
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should pass when #from comes before #to" do
|
335
|
-
|
335
|
+
expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("cat")
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
@@ -342,8 +342,8 @@ describe Spec::Matchers::Change do
|
|
342
342
|
@instance.some_value = "string"
|
343
343
|
def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
344
344
|
|
345
|
-
|
346
|
-
|
347
|
-
}.
|
345
|
+
expect {
|
346
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value)
|
347
|
+
}.to_not raise_error
|
348
348
|
end
|
349
349
|
end
|