public
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
Delegated #should and #should_not for an example to the example's subject
jferris (author)
Sat Nov 08 12:03:12 -0800 2008
commit  dc51a976280b7d9638e9b87c3c7b3c13d3d0b207
tree    40fc31d7cb5a5ae78a7a981eacae542ec84e5f91
parent  dc9edc66ad29a482cab467c2423d6bb25093bf75
...
89
90
91
 
 
 
 
 
 
 
 
92
93
94
...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
0
@@ -89,6 +89,14 @@ module Spec
0
         @subject ||= instance_variable_get(subject_variable_name)
0
       end
0
 
0
+      def should(matcher)
0
+        subject.should(matcher)
0
+      end
0
+
0
+      def should_not(matcher)
0
+        subject.should_not(matcher)
0
+      end
0
+
0
       protected
0
       include Matchers
0
       include Pending
...
168
169
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
172
173
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
0
@@ -168,6 +168,68 @@ module Spec
0
           example.subject.should equal(expected)
0
         end
0
       end
0
+
0
+      describe "#should" do
0
+        with_sandboxed_options do
0
+
0
+          attr_reader :example_group, :example, :success
0
+
0
+          before do
0
+            @example_group = Class.new(ExampleGroup) do
0
+              def subject; @actual; end
0
+              before(:each) { @actual = 'expected' }
0
+              it { should eql('expected') }
0
+            end
0
+            @example = @example_group.examples.first
0
+
0
+            @success = example_group.run
0
+          end
0
+
0
+          it "should create an example using the description from the matcher" do
0
+            example.description.should == 'should eql "expected"'
0
+          end
0
+
0
+          it "should test the matcher returned from the block" do
0
+            success.should be_true
0
+          end
0
+
0
+          after do
0
+            ExampleGroup.reset
0
+          end
0
+
0
+        end
0
+      end
0
+
0
+      describe "#should_not" do
0
+        with_sandboxed_options do
0
+
0
+          attr_reader :example_group, :example, :success
0
+
0
+          before do
0
+            @example_group = Class.new(ExampleGroup) do
0
+              def subject; @actual; end
0
+              before(:each) { @actual = 'expected' }
0
+              it { should_not eql('unexpected') }
0
+            end
0
+            @example = @example_group.examples.first
0
+
0
+            @success = example_group.run
0
+          end
0
+
0
+          it "should create an example using the description from the matcher" do
0
+            example.description.should == 'should not eql "unexpected"'
0
+          end
0
+
0
+          it "should test the matcher returned from the block" do
0
+            success.should be_true
0
+          end
0
+
0
+          after do
0
+            ExampleGroup.reset
0
+          end
0
+
0
+        end
0
+      end
0
     end
0
 
0
     describe "#options" do

Comments