rspec 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.rdoc +59 -32
  3. data/Manifest.txt +6 -0
  4. data/Rakefile +2 -2
  5. data/examples/passing/options_example.rb +31 -0
  6. data/examples/passing/options_formatter.rb +20 -0
  7. data/features/expectations/expect_change.feature +65 -0
  8. data/features/expectations/expect_error.feature +44 -0
  9. data/lib/spec/example/example_group_factory.rb +4 -2
  10. data/lib/spec/example/example_group_methods.rb +5 -1
  11. data/lib/spec/example/example_group_proxy.rb +8 -0
  12. data/lib/spec/example/example_matcher.rb +2 -3
  13. data/lib/spec/example/example_methods.rb +14 -1
  14. data/lib/spec/example/example_proxy.rb +3 -4
  15. data/lib/spec/example/subject.rb +7 -7
  16. data/lib/spec/interop/test.rb +2 -1
  17. data/lib/spec/matchers/be_close.rb +5 -5
  18. data/lib/spec/matchers/be_instance_of.rb +2 -2
  19. data/lib/spec/matchers/be_kind_of.rb +2 -2
  20. data/lib/spec/matchers/compatibility.rb +2 -2
  21. data/lib/spec/matchers/eql.rb +4 -4
  22. data/lib/spec/matchers/equal.rb +18 -8
  23. data/lib/spec/matchers/extensions/instance_exec.rb +1 -3
  24. data/lib/spec/matchers/include.rb +4 -4
  25. data/lib/spec/matchers/match.rb +2 -2
  26. data/lib/spec/matchers/operator_matcher.rb +3 -2
  27. data/lib/spec/mocks/methods.rb +9 -0
  28. data/lib/spec/mocks/mock.rb +34 -24
  29. data/lib/spec/mocks/proxy.rb +1 -0
  30. data/lib/spec/mocks/spec_methods.rb +5 -5
  31. data/lib/spec/runner.rb +1 -2
  32. data/lib/spec/runner/configuration.rb +0 -0
  33. data/lib/spec/runner/drb_command_line.rb +2 -0
  34. data/lib/spec/runner/formatter/base_text_formatter.rb +1 -1
  35. data/lib/spec/runner/formatter/no_op_method_missing.rb +1 -1
  36. data/lib/spec/version.rb +1 -1
  37. data/spec/spec/example/example_group_proxy_spec.rb +24 -0
  38. data/spec/spec/example/example_methods_spec.rb +12 -0
  39. data/spec/spec/example/predicate_matcher_spec.rb +0 -0
  40. data/spec/spec/example/subject_spec.rb +16 -6
  41. data/spec/spec/matchers/change_spec.rb +85 -85
  42. data/spec/spec/matchers/compatibility_spec.rb +16 -22
  43. data/spec/spec/matchers/equal_spec.rb +33 -9
  44. data/spec/spec/matchers/have_spec.rb +1 -8
  45. data/spec/spec/mocks/mock_ordering_spec.rb +10 -0
  46. data/spec/spec/mocks/mock_spec.rb +106 -93
  47. data/spec/spec/mocks/stub_chain_spec.rb +27 -0
  48. data/spec/spec/mocks/stub_spec.rb +9 -5
  49. data/spec/spec/runner/configuration_spec.rb +0 -0
  50. data/spec/spec/runner/drb_command_line_spec.rb +1 -1
  51. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +31 -46
  52. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +25 -28
  53. data/spec/spec/runner/formatter/html_formatter_spec.rb +3 -19
  54. data/spec/spec/runner/formatter/profile_formatter_spec.rb +3 -18
  55. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +4 -28
  56. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +31 -46
  57. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +7 -10
  58. data/spec/spec/runner/reporter_spec.rb +1 -1
  59. data/spec/spec_helper.rb +4 -0
  60. data/spec/support/macros.rb +29 -0
  61. metadata +36 -8
  62. 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(name, stubs_and_options={})
24
- Spec::Mocks::Mock.new(name, stubs_and_options)
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
@@ -58,8 +58,7 @@ module Spec
58
58
  end
59
59
 
60
60
  def run
61
- return true if options.examples_run?
62
- options.run_examples
61
+ options.examples_run? || options.run_examples
63
62
  end
64
63
 
65
64
  end
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, ignore)
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
 
@@ -6,7 +6,7 @@ module Spec
6
6
  if include_private
7
7
  true
8
8
  else
9
- !private_methods.include?(message.to_s)
9
+ !private_methods.any? {|m| [message.to_s, message.to_sym].include?(m)}
10
10
  end
11
11
  end
12
12
 
@@ -3,7 +3,7 @@ module Spec # :nodoc:
3
3
  unless defined? MAJOR
4
4
  MAJOR = 1
5
5
  MINOR = 2
6
- TINY = 4
6
+ TINY = 5
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
9
9
 
@@ -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
@@ -48,8 +48,8 @@ module Spec
48
48
  end
49
49
 
50
50
  describe "defined in a top level group" do
51
- it "is available in a nested group (subclass)" do
52
- klass = Class.new do
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
- subclass = Class.new(klass)
70
-
71
- object = subclass.new
72
- object.subject.should == [1,2,3]
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
- lambda {@instance.some_value = 6}.should change(@instance, :some_value)
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
- lambda do
20
- lambda {}.should change(@instance, :some_value)
21
- end.should fail_with("some_value should have changed, but is still 5")
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
- lambda { }.should_not change(@instance, :some_value)
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
- lambda do
41
- lambda {@instance.some_value = 6}.should_not change(@instance, :some_value)
42
- end.should fail_with("some_value should not have changed, but did change from 5 to 6")
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
- lambda {@instance.some_value = 6}.should change { @instance.some_value }
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
- lambda do
58
- lambda {}.should change{ @instance.some_value }
59
- end.should fail_with("result should have changed, but is still 5")
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
- lambda do
64
- lambda {}.should change do; end
65
- end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
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
- lambda {}.should_not change{ @instance.some_value }
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
- lambda do
85
- lambda {@instance.some_value = 6}.should_not change { @instance.some_value }
86
- end.should fail_with("result should not have changed, but did change from 5 to 6")
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
- lambda do
91
- lambda {}.should_not change do; end
92
- end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
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
- lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by(1)
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
- lambda do
108
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by(1)
109
- end.should fail_with("some_value should have been changed by 1, but was changed by 2")
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
- lambda do
114
- lambda { @instance.some_value -= 1 }.should change(@instance, :some_value).by(1)
115
- end.should fail_with("some_value should have been changed by 1, but was changed by -1")
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
- lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by(1)
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
- lambda do
131
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by(1)
132
- end.should fail_with("result should have been changed by 1, but was changed by 2")
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
- lambda do
137
- lambda { @instance.some_value -= 1 }.should change{@instance.some_value}.by(1)
138
- end.should fail_with("result should have been changed by 1, but was changed by -1")
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
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(1)
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
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(2)
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
- lambda do
158
- lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by_at_least(2)
159
- end.should fail_with("some_value should have been changed by at least 2, but was changed by 1")
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
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(1)
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
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(2)
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
- lambda do
180
- lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by_at_least(2)
181
- end.should fail_with("result should have been changed by at least 2, but was changed by 1")
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
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(3)
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
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(2)
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
- lambda do
202
- lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(1)
203
- end.should fail_with("some_value should have been changed by at most 1, but was changed by 2")
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
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(3)
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
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(2)
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
- lambda do
224
- lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(1)
225
- end.should fail_with("result should have been changed by at most 1, but was changed by 2")
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
- lambda { @instance.some_value = "astring" }.should change(@instance, :some_value).from("string")
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
- lambda do
241
- lambda { @instance.some_value = "knot" }.should change(@instance, :some_value).from("cat")
242
- end.should fail_with("some_value should have initially been \"cat\", but was \"string\"")
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
- lambda { @instance.some_value = "astring" }.should change{@instance.some_value}.from("string")
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
- lambda do
258
- lambda { @instance.some_value = "knot" }.should change{@instance.some_value}.from("cat")
259
- end.should fail_with("result should have initially been \"cat\", but was \"string\"")
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
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat")
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
- lambda do
275
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("dog")
276
- end.should fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
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
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat")
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
- lambda do
292
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("dog")
293
- end.should fail_with("result should have been changed to \"dog\", but is now \"cat\"")
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
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat").from("string")
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
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("cat")
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
- lambda do
313
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("dog")
314
- end.should fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
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
- lambda do
319
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("not_string").to("cat")
320
- end.should fail_with("some_value should have initially been \"not_string\", but was \"string\"")
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
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat").from("string")
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
- lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("cat")
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
- lambda {
346
- lambda { @instance.some_value = "cat" }.should change(@instance, :some_value)
347
- }.should_not raise_error
345
+ expect {
346
+ expect { @instance.some_value = "cat" }.to change(@instance, :some_value)
347
+ }.to_not raise_error
348
348
  end
349
349
  end