spicycode-micronaut 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Rakefile +1 -1
  2. data/examples/lib/micronaut/{behaviour_group_example.rb → behaviour_example.rb} +15 -13
  3. data/examples/lib/micronaut/configuration_example.rb +4 -4
  4. data/examples/lib/micronaut/example_example.rb +46 -0
  5. data/examples/lib/micronaut/expectations/extensions/object_example.rb +63 -76
  6. data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +4 -3
  7. data/examples/lib/micronaut/formatters/base_formatter_example.rb +2 -2
  8. data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
  9. data/examples/lib/micronaut/formatters/progress_formatter_example.rb +8 -29
  10. data/examples/lib/micronaut/matchers/be_close_example.rb +48 -38
  11. data/examples/lib/micronaut/matchers/be_example.rb +287 -246
  12. data/examples/lib/micronaut/matchers/change_example.rb +306 -275
  13. data/examples/lib/micronaut/matchers/description_generation_example.rb +168 -160
  14. data/examples/lib/micronaut/matchers/eql_example.rb +30 -24
  15. data/examples/lib/micronaut/matchers/equal_example.rb +31 -25
  16. data/examples/lib/micronaut/matchers/handler_example.rb +36 -29
  17. data/examples/lib/micronaut/matchers/has_example.rb +57 -49
  18. data/examples/lib/micronaut/matchers/include_example.rb +89 -74
  19. data/examples/lib/micronaut/matchers/match_example.rb +33 -29
  20. data/examples/lib/micronaut/world_example.rb +4 -4
  21. data/lib/micronaut/{behaviour_group.rb → behaviour.rb} +8 -7
  22. data/lib/micronaut/configuration.rb +1 -1
  23. data/lib/micronaut/example.rb +5 -1
  24. data/lib/micronaut/formatters/base_formatter.rb +6 -6
  25. data/lib/micronaut/formatters/base_text_formatter.rb +8 -13
  26. data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
  27. data/lib/micronaut/formatters/progress_formatter.rb +1 -0
  28. data/lib/micronaut/formatters.rb +1 -0
  29. data/lib/micronaut/kernel_extensions.rb +1 -1
  30. data/lib/micronaut/runner.rb +1 -4
  31. data/lib/micronaut/runner_options.rb +11 -4
  32. data/lib/micronaut.rb +2 -2
  33. metadata +7 -4
@@ -5,325 +5,356 @@ class SomethingExpected
5
5
  attr_accessor :some_value
6
6
  end
7
7
 
8
- describe "should change(actual, message)" do
9
- before do
10
- @instance = SomethingExpected.new
11
- @instance.some_value = 5
12
- end
13
-
14
- it "should pass when actual is modified by the block" do
15
- lambda {@instance.some_value = 6}.should change(@instance, :some_value)
16
- end
17
-
18
- it "should fail when actual is not modified by the block" do
19
- lambda do
20
- lambda {}.should change(@instance, :some_value)
21
- end.should fail_with("some_value should have changed, but is still 5")
22
- end
23
- end
24
-
25
- describe "should_not change(actual, message)" do
26
- before do
27
- @instance = SomethingExpected.new
28
- @instance.some_value = 5
29
- end
30
-
31
- it "should pass when actual is not modified by the block" do
32
- lambda { }.should_not change(@instance, :some_value)
33
- end
34
-
35
- it "should fail when actual is not modified by the block" do
36
- lambda do
37
- lambda {@instance.some_value = 6}.should_not change(@instance, :some_value)
38
- end.should fail_with("some_value should not have changed, but did change from 5 to 6")
39
- end
40
- end
41
-
42
- describe "should change { block }" do
43
- before do
44
- @instance = SomethingExpected.new
45
- @instance.some_value = 5
46
- end
47
-
48
- it "should pass when actual is modified by the block" do
49
- lambda {@instance.some_value = 6}.should change { @instance.some_value }
50
- end
51
-
52
- it "should fail when actual is not modified by the block" do
53
- lambda do
54
- lambda {}.should change{ @instance.some_value }
55
- end.should fail_with("result should have changed, but is still 5")
56
- end
57
-
58
- it "should warn if passed a block using do/end instead of {}" do
59
- lambda do
60
- lambda {}.should change do; end
61
- end.should raise_error(Micronaut::Matchers::MatcherError, /block passed to should or should_not/)
62
- end
63
- end
64
-
65
- describe "should_not change { block }" do
66
- before do
67
- @instance = SomethingExpected.new
68
- @instance.some_value = 5
69
- end
70
-
71
- it "should pass when actual is modified by the block" do
72
- lambda {}.should_not change{ @instance.some_value }
73
- end
74
-
75
- it "should fail when actual is not modified by the block" do
76
- lambda do
77
- lambda {@instance.some_value = 6}.should_not change { @instance.some_value }
78
- end.should fail_with("result should not have changed, but did change from 5 to 6")
79
- end
80
-
81
- it "should warn if passed a block using do/end instead of {}" do
82
- lambda do
83
- lambda {}.should_not change do; end
84
- end.should raise_error(Micronaut::Matchers::MatcherError, /block passed to should or should_not/)
85
- end
86
- end
87
-
88
- describe "should change(actual, message).by(expected)" do
89
- before do
90
- @instance = SomethingExpected.new
91
- @instance.some_value = 5
92
- end
93
-
94
- it "should pass when attribute is changed by expected amount" do
95
- lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by(1)
96
- end
97
-
98
- it "should fail when the attribute is changed by unexpected amount" do
99
- lambda do
100
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by(1)
101
- end.should fail_with("some_value should have been changed by 1, but was changed by 2")
102
- end
103
-
104
- it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
105
- lambda do
106
- lambda { @instance.some_value -= 1 }.should change(@instance, :some_value).by(1)
107
- end.should fail_with("some_value should have been changed by 1, but was changed by -1")
108
- end
109
- end
110
-
111
- describe "should change{ block }.by(expected)" do
112
- before do
113
- @instance = SomethingExpected.new
114
- @instance.some_value = 5
115
- end
116
-
117
- it "should pass when attribute is changed by expected amount" do
118
- lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by(1)
119
- end
120
-
121
- it "should fail when the attribute is changed by unexpected amount" do
122
- lambda do
123
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by(1)
124
- end.should fail_with("result should have been changed by 1, but was changed by 2")
125
- end
126
-
127
- it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
128
- lambda do
129
- lambda { @instance.some_value -= 1 }.should change{@instance.some_value}.by(1)
130
- end.should fail_with("result should have been changed by 1, but was changed by -1")
131
- end
132
- end
133
-
134
- describe "should change(actual, message).by_at_least(expected)" do
135
- before do
136
- @instance = SomethingExpected.new
137
- @instance.some_value = 5
138
- end
139
-
140
- it "should pass when attribute is changed by greater than the expected amount" do
141
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(1)
142
- end
143
-
144
- it "should pass when attribute is changed by the expected amount" do
145
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(2)
146
- end
147
-
148
- it "should fail when the attribute is changed by less than the expected amount" do
149
- lambda do
150
- lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by_at_least(2)
151
- end.should fail_with("some_value should have been changed by at least 2, but was changed by 1")
152
- end
153
-
154
- end
8
+ describe Micronaut::Matchers do
155
9
 
156
- describe "should change{ block }.by_at_least(expected)" do
157
- before do
158
- @instance = SomethingExpected.new
159
- @instance.some_value = 5
10
+ describe "should change(actual, message)" do
11
+
12
+ before do
13
+ @instance = SomethingExpected.new
14
+ @instance.some_value = 5
15
+ end
16
+
17
+ it "should pass when actual is modified by the block" do
18
+ lambda {@instance.some_value = 6}.should change(@instance, :some_value)
19
+ end
20
+
21
+ it "should fail when actual is not modified by the block" do
22
+ lambda do
23
+ lambda {}.should change(@instance, :some_value)
24
+ end.should fail_with("some_value should have changed, but is still 5")
25
+ end
26
+
160
27
  end
161
28
 
162
- it "should pass when attribute is changed by greater than expected amount" do
163
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(1)
29
+ describe "should_not change(actual, message)" do
30
+
31
+ before do
32
+ @instance = SomethingExpected.new
33
+ @instance.some_value = 5
34
+ end
35
+
36
+ it "should pass when actual is not modified by the block" do
37
+ lambda { }.should_not change(@instance, :some_value)
38
+ end
39
+
40
+ it "should fail when actual is not modified by the block" do
41
+ lambda do
42
+ lambda {@instance.some_value = 6}.should_not change(@instance, :some_value)
43
+ end.should fail_with("some_value should not have changed, but did change from 5 to 6")
44
+ end
45
+
164
46
  end
165
-
166
- it "should pass when attribute is changed by the expected amount" do
167
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(2)
168
- end
169
47
 
170
- it "should fail when the attribute is changed by less than the unexpected amount" do
171
- lambda do
172
- lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by_at_least(2)
173
- end.should fail_with("result should have been changed by at least 2, but was changed by 1")
48
+ describe "should change { block }" do
49
+
50
+ before do
51
+ @instance = SomethingExpected.new
52
+ @instance.some_value = 5
53
+ end
54
+
55
+ it "should pass when actual is modified by the block" do
56
+ lambda {@instance.some_value = 6}.should change { @instance.some_value }
57
+ end
58
+
59
+ it "should fail when actual is not modified by the block" do
60
+ lambda do
61
+ lambda {}.should change{ @instance.some_value }
62
+ end.should fail_with("result should have changed, but is still 5")
63
+ end
64
+
65
+ it "should warn if passed a block using do/end instead of {}" do
66
+ lambda do
67
+ lambda {}.should change do; end
68
+ end.should raise_error(Micronaut::Matchers::MatcherError, /block passed to should or should_not/)
69
+ end
70
+
174
71
  end
175
- end
176
72
 
177
-
178
- describe "should change(actual, message).by_at_most(expected)" do
179
- before do
180
- @instance = SomethingExpected.new
181
- @instance.some_value = 5
73
+ describe "should_not change { block }" do
74
+
75
+ before do
76
+ @instance = SomethingExpected.new
77
+ @instance.some_value = 5
78
+ end
79
+
80
+ it "should pass when actual is modified by the block" do
81
+ lambda {}.should_not change{ @instance.some_value }
82
+ end
83
+
84
+ it "should fail when actual is not modified by the block" do
85
+ lambda do
86
+ lambda {@instance.some_value = 6}.should_not change { @instance.some_value }
87
+ end.should fail_with("result should not have changed, but did change from 5 to 6")
88
+ end
89
+
90
+ it "should warn if passed a block using do/end instead of {}" do
91
+ lambda do
92
+ lambda {}.should_not change do; end
93
+ end.should raise_error(Micronaut::Matchers::MatcherError, /block passed to should or should_not/)
94
+ end
95
+
182
96
  end
183
97
 
184
- it "should pass when attribute is changed by less than the expected amount" do
185
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(3)
98
+ describe "should change(actual, message).by(expected)" do
99
+
100
+ before do
101
+ @instance = SomethingExpected.new
102
+ @instance.some_value = 5
103
+ end
104
+
105
+ it "should pass when attribute is changed by expected amount" do
106
+ lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by(1)
107
+ end
108
+
109
+ it "should fail when the attribute is changed by unexpected amount" do
110
+ lambda do
111
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by(1)
112
+ end.should fail_with("some_value should have been changed by 1, but was changed by 2")
113
+ end
114
+
115
+ it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
116
+ lambda do
117
+ lambda { @instance.some_value -= 1 }.should change(@instance, :some_value).by(1)
118
+ end.should fail_with("some_value should have been changed by 1, but was changed by -1")
119
+ end
120
+
186
121
  end
187
-
188
- it "should pass when attribute is changed by the expected amount" do
189
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(2)
190
- end
191
122
 
192
- it "should fail when the attribute is changed by greater than the expected amount" do
193
- lambda do
194
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(1)
195
- end.should fail_with("some_value should have been changed by at most 1, but was changed by 2")
123
+ describe "should change{ block }.by(expected)" do
124
+
125
+ before do
126
+ @instance = SomethingExpected.new
127
+ @instance.some_value = 5
128
+ end
129
+
130
+ it "should pass when attribute is changed by expected amount" do
131
+ lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by(1)
132
+ end
133
+
134
+ it "should fail when the attribute is changed by unexpected amount" do
135
+ lambda do
136
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by(1)
137
+ end.should fail_with("result should have been changed by 1, but was changed by 2")
138
+ end
139
+
140
+ it "should fail when the attribute is changed by unexpected amount in the opposite direction" do
141
+ lambda do
142
+ lambda { @instance.some_value -= 1 }.should change{@instance.some_value}.by(1)
143
+ end.should fail_with("result should have been changed by 1, but was changed by -1")
144
+ end
145
+
196
146
  end
197
147
 
198
- end
148
+ describe "should change(actual, message).by_at_least(expected)" do
149
+
150
+ before do
151
+ @instance = SomethingExpected.new
152
+ @instance.some_value = 5
153
+ end
199
154
 
200
- describe "should change{ block }.by_at_most(expected)" do
201
- before do
202
- @instance = SomethingExpected.new
203
- @instance.some_value = 5
204
- end
155
+ it "should pass when attribute is changed by greater than the expected amount" do
156
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(1)
157
+ end
205
158
 
206
- it "should pass when attribute is changed by less than expected amount" do
207
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(3)
208
- end
209
-
210
- it "should pass when attribute is changed by the expected amount" do
211
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(2)
212
- end
159
+ it "should pass when attribute is changed by the expected amount" do
160
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(2)
161
+ end
213
162
 
214
- it "should fail when the attribute is changed by greater than the unexpected amount" do
215
- lambda do
216
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(1)
217
- end.should fail_with("result should have been changed by at most 1, but was changed by 2")
218
- end
219
- end
163
+ it "should fail when the attribute is changed by less than the expected amount" do
164
+ lambda do
165
+ lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by_at_least(2)
166
+ end.should fail_with("some_value should have been changed by at least 2, but was changed by 1")
167
+ end
220
168
 
221
- describe "should change(actual, message).from(old)" do
222
- before do
223
- @instance = SomethingExpected.new
224
- @instance.some_value = 'string'
225
169
  end
226
170
 
227
- it "should pass when attribute is == to expected value before executing block" do
228
- lambda { @instance.some_value = "astring" }.should change(@instance, :some_value).from("string")
171
+ describe "should change{ block }.by_at_least(expected)" do
172
+
173
+ before do
174
+ @instance = SomethingExpected.new
175
+ @instance.some_value = 5
176
+ end
177
+
178
+ it "should pass when attribute is changed by greater than expected amount" do
179
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(1)
180
+ end
181
+
182
+ it "should pass when attribute is changed by the expected amount" do
183
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(2)
184
+ end
185
+
186
+ it "should fail when the attribute is changed by less than the unexpected amount" do
187
+ lambda do
188
+ lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by_at_least(2)
189
+ end.should fail_with("result should have been changed by at least 2, but was changed by 1")
190
+ end
191
+
229
192
  end
230
193
 
231
- it "should fail when attribute is not == to expected value before executing block" do
232
- lambda do
233
- lambda { @instance.some_value = "knot" }.should change(@instance, :some_value).from("cat")
234
- end.should fail_with("some_value should have initially been \"cat\", but was \"string\"")
235
- end
236
- end
194
+ describe "should change(actual, message).by_at_most(expected)" do
195
+
196
+ before do
197
+ @instance = SomethingExpected.new
198
+ @instance.some_value = 5
199
+ end
237
200
 
238
- describe "should change{ block }.from(old)" do
239
- before do
240
- @instance = SomethingExpected.new
241
- @instance.some_value = 'string'
242
- end
201
+ it "should pass when attribute is changed by less than the expected amount" do
202
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(3)
203
+ end
243
204
 
244
- it "should pass when attribute is == to expected value before executing block" do
245
- lambda { @instance.some_value = "astring" }.should change{@instance.some_value}.from("string")
246
- end
205
+ it "should pass when attribute is changed by the expected amount" do
206
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(2)
207
+ end
247
208
 
248
- it "should fail when attribute is not == to expected value before executing block" do
249
- lambda do
250
- lambda { @instance.some_value = "knot" }.should change{@instance.some_value}.from("cat")
251
- end.should fail_with("result should have initially been \"cat\", but was \"string\"")
252
- end
253
- end
209
+ it "should fail when the attribute is changed by greater than the expected amount" do
210
+ lambda do
211
+ lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(1)
212
+ end.should fail_with("some_value should have been changed by at most 1, but was changed by 2")
213
+ end
254
214
 
255
- describe "should change(actual, message).to(new)" do
256
- before do
257
- @instance = SomethingExpected.new
258
- @instance.some_value = 'string'
259
- end
260
-
261
- it "should pass when attribute is == to expected value after executing block" do
262
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat")
263
215
  end
264
216
 
265
- it "should fail when attribute is not == to expected value after executing block" do
266
- lambda do
267
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("dog")
268
- end.should fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
217
+ describe "should change{ block }.by_at_most(expected)" do
218
+
219
+ before do
220
+ @instance = SomethingExpected.new
221
+ @instance.some_value = 5
222
+ end
223
+
224
+ it "should pass when attribute is changed by less than expected amount" do
225
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(3)
226
+ end
227
+
228
+ it "should pass when attribute is changed by the expected amount" do
229
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(2)
230
+ end
231
+
232
+ it "should fail when the attribute is changed by greater than the unexpected amount" do
233
+ lambda do
234
+ lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(1)
235
+ end.should fail_with("result should have been changed by at most 1, but was changed by 2")
236
+ end
237
+
269
238
  end
270
- end
271
239
 
272
- describe "should change{ block }.to(new)" do
273
- before do
274
- @instance = SomethingExpected.new
275
- @instance.some_value = 'string'
276
- end
277
-
278
- it "should pass when attribute is == to expected value after executing block" do
279
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat")
240
+ describe "should change(actual, message).from(old)" do
241
+
242
+ before do
243
+ @instance = SomethingExpected.new
244
+ @instance.some_value = 'string'
245
+ end
246
+
247
+ it "should pass when attribute is == to expected value before executing block" do
248
+ lambda { @instance.some_value = "astring" }.should change(@instance, :some_value).from("string")
249
+ end
250
+
251
+ it "should fail when attribute is not == to expected value before executing block" do
252
+ lambda do
253
+ lambda { @instance.some_value = "knot" }.should change(@instance, :some_value).from("cat")
254
+ end.should fail_with("some_value should have initially been \"cat\", but was \"string\"")
255
+ end
256
+
280
257
  end
281
258
 
282
- it "should fail when attribute is not == to expected value after executing block" do
283
- lambda do
284
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("dog")
285
- end.should fail_with("result should have been changed to \"dog\", but is now \"cat\"")
259
+ describe "should change{ block }.from(old)" do
260
+
261
+ before do
262
+ @instance = SomethingExpected.new
263
+ @instance.some_value = 'string'
264
+ end
265
+
266
+ it "should pass when attribute is == to expected value before executing block" do
267
+ lambda { @instance.some_value = "astring" }.should change{@instance.some_value}.from("string")
268
+ end
269
+
270
+ it "should fail when attribute is not == to expected value before executing block" do
271
+ lambda do
272
+ lambda { @instance.some_value = "knot" }.should change{@instance.some_value}.from("cat")
273
+ end.should fail_with("result should have initially been \"cat\", but was \"string\"")
274
+ end
275
+
286
276
  end
287
- end
288
277
 
289
- describe "should change(actual, message).from(old).to(new)" do
290
- before do
291
- @instance = SomethingExpected.new
292
- @instance.some_value = 'string'
293
- end
294
-
295
- it "should pass when #to comes before #from" do
296
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat").from("string")
278
+ describe "should change(actual, message).to(new)" do
279
+
280
+ before do
281
+ @instance = SomethingExpected.new
282
+ @instance.some_value = 'string'
283
+ end
284
+
285
+ it "should pass when attribute is == to expected value after executing block" do
286
+ lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat")
287
+ end
288
+
289
+ it "should fail when attribute is not == to expected value after executing block" do
290
+ lambda do
291
+ lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("dog")
292
+ end.should fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
293
+ end
294
+
297
295
  end
298
296
 
299
- it "should pass when #from comes before #to" do
300
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("cat")
297
+ describe "should change{ block }.to(new)" do
298
+
299
+ before do
300
+ @instance = SomethingExpected.new
301
+ @instance.some_value = 'string'
302
+ end
303
+
304
+ it "should pass when attribute is == to expected value after executing block" do
305
+ lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat")
306
+ end
307
+
308
+ it "should fail when attribute is not == to expected value after executing block" do
309
+ lambda do
310
+ lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("dog")
311
+ end.should fail_with("result should have been changed to \"dog\", but is now \"cat\"")
312
+ end
313
+
301
314
  end
302
- end
303
315
 
304
- describe "should change{ block }.from(old).to(new)" do
305
- before do
306
- @instance = SomethingExpected.new
307
- @instance.some_value = 'string'
308
- end
309
-
310
- it "should pass when #to comes before #from" do
311
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat").from("string")
316
+ describe "should change(actual, message).from(old).to(new)" do
317
+
318
+ before do
319
+ @instance = SomethingExpected.new
320
+ @instance.some_value = 'string'
321
+ end
322
+
323
+ it "should pass when #to comes before #from" do
324
+ lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat").from("string")
325
+ end
326
+
327
+ it "should pass when #from comes before #to" do
328
+ lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("cat")
329
+ end
330
+
312
331
  end
313
332
 
314
- it "should pass when #from comes before #to" do
315
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("cat")
333
+ describe "should change{ block }.from(old).to(new)" do
334
+
335
+ before do
336
+ @instance = SomethingExpected.new
337
+ @instance.some_value = 'string'
338
+ end
339
+
340
+ it "should pass when #to comes before #from" do
341
+ lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat").from("string")
342
+ end
343
+
344
+ it "should pass when #from comes before #to" do
345
+ lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("cat")
346
+ end
347
+
316
348
  end
317
- end
318
349
 
319
- describe Micronaut::Matchers::Change do
320
350
  it "should work when the receiver has implemented #send" do
321
351
  @instance = SomethingExpected.new
322
352
  @instance.some_value = "string"
323
353
  def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end
324
-
325
- lambda {
354
+
355
+ lambda do
326
356
  lambda { @instance.some_value = "cat" }.should change(@instance, :some_value)
327
- }.should_not raise_error
357
+ end.should_not raise_error
328
358
  end
329
- end
359
+
360
+ end