Skip to content
This repository
  • 2 commits
  • 31 files changed
  • 6 comments
  • 2 contributors
Sep 14, 2012
Tom Stuart indicative docstrings
This was a pull request (#71) from Tom Stuart that I didn't merge until several
months later, so I had to address some merge conflicts. In addition, the
original intent was to offer the end user a configuration option for the
"voice" of the message (e.g. "should be x" vs "is x"), but I made it check if
the matcher responds to new methods docstring_for_should or
docstring_for_should_not and use those. This way all the internal matchers do
the right thing, but external matchers will still work without rspec trying to
convert the mode of it's docstring.
2f0d105
David Chelimsky fix cuke for rubinius a5c6f41

Showing 31 changed files with 342 additions and 170 deletions. Show diff stats Hide diff stats

  1. 2  features/custom_matchers/access_running_example.feature
  2. 24  features/custom_matchers/define_matcher.feature
  3. 4  features/custom_matchers/define_matcher_with_fluent_interface.feature
  4. 14  features/implicit_docstrings.feature
  5. 3  lib/rspec/expectations.rb
  6. 22  lib/rspec/matchers.rb
  7. 48  lib/rspec/matchers/built_in/be.rb
  8. 18  lib/rspec/matchers/built_in/be_within.rb
  9. 10  lib/rspec/matchers/built_in/change.rb
  10. 9  lib/rspec/matchers/built_in/eq.rb
  11. 8  lib/rspec/matchers/built_in/eql.rb
  12. 8  lib/rspec/matchers/built_in/equal.rb
  13. 12  lib/rspec/matchers/built_in/has.rb
  14. 8  lib/rspec/matchers/built_in/have.rb
  15. 8  lib/rspec/matchers/built_in/include.rb
  16. 9  lib/rspec/matchers/built_in/match.rb
  17. 8  lib/rspec/matchers/built_in/match_array.rb
  18. 8  lib/rspec/matchers/built_in/raise_error.rb
  19. 8  lib/rspec/matchers/built_in/respond_to.rb
  20. 8  lib/rspec/matchers/built_in/satisfy.rb
  21. 8  lib/rspec/matchers/built_in/throw_symbol.rb
  22. 15  lib/rspec/matchers/generated_descriptions.rb
  23. 17  lib/rspec/matchers/matcher.rb
  24. 14  lib/rspec/matchers/operator_matcher.rb
  25. 33  spec/rspec/matchers/be_spec.rb
  26. 5  spec/rspec/matchers/be_within_spec.rb
  27. 50  spec/rspec/matchers/change_spec.rb
  28. 93  spec/rspec/matchers/description_generation_spec.rb
  29. 5  spec/rspec/matchers/include_spec.rb
  30. 30  spec/rspec/matchers/respond_to_spec.rb
  31. 3  spec/rspec/matchers/satisfy_spec.rb
2  features/custom_matchers/access_running_example.feature
@@ -48,6 +48,6 @@ Feature: access running example
48 48
       """
49 49
     When I run `rspec ./example_spec.rb`
50 50
     Then the output should contain "1 example, 1 failure"
51  
-    And the output should contain "undefined local variable"
  51
+    And the output should contain "undefined"
52 52
     And the output should contain "RSpec::Matchers::DSL::Matcher"
53 53
     And the output should not contain "ExampleGroup"
24  features/custom_matchers/define_matcher.feature
@@ -37,8 +37,8 @@ Feature: define matcher
37 37
     When I run `rspec ./matcher_with_default_message_spec.rb --format documentation`
38 38
     Then the exit status should not be 0
39 39
 
40  
-    And the output should contain "should be a multiple of 3"
41  
-    And the output should contain "should not be a multiple of 4"
  40
+    And the output should contain "is a multiple of 3"
  41
+    And the output should contain "is not a multiple of 4"
42 42
     And the output should contain "Failure/Error: it {should be_a_multiple_of(4)}"
43 43
     And the output should contain "Failure/Error: it {should_not be_a_multiple_of(3)}"
44 44
 
@@ -94,17 +94,19 @@ Feature: define matcher
94 94
     And the stdout should contain "1 example, 1 failure"
95 95
     And the stdout should contain "expected that 9 would not be a multiple of 3"
96 96
 
97  
-  Scenario: overriding the description
  97
+  Scenario: overriding the docstrings
98 98
     Given a file named "matcher_overriding_description_spec.rb" with:
99 99
       """
100 100
       require 'rspec/expectations'
101  
-
102 101
       RSpec::Matchers.define :be_a_multiple_of do |expected|
103 102
         match do |actual|
104 103
           actual % expected == 0
105 104
         end
106  
-        description do
107  
-          "be multiple of #{expected}"
  105
+        docstring_for_should do
  106
+          "is multiple of #{expected}"
  107
+        end
  108
+        docstring_for_should_not do
  109
+          "is not multiple of #{expected}"
108 110
         end
109 111
       end
110 112
 
@@ -119,14 +121,13 @@ Feature: define matcher
119 121
     When I run `rspec ./matcher_overriding_description_spec.rb --format documentation`
120 122
     Then the exit status should be 0
121 123
     And the stdout should contain "2 examples, 0 failures"
122  
-    And the stdout should contain "should be multiple of 3"
123  
-    And the stdout should contain "should not be multiple of 4"
  124
+    And the stdout should contain "is multiple of 3"
  125
+    And the stdout should contain "is not multiple of 4"
124 126
 
125 127
   Scenario: with no args
126 128
     Given a file named "matcher_with_no_args_spec.rb" with:
127 129
       """
128 130
       require 'rspec/expectations'
129  
-
130 131
       RSpec::Matchers.define :have_7_fingers do
131 132
         match do |thing|
132 133
           thing.fingers.length == 7
@@ -144,13 +145,12 @@ Feature: define matcher
144 145
     When I run `rspec ./matcher_with_no_args_spec.rb --format documentation`
145 146
     Then the exit status should be 0
146 147
     And the stdout should contain "1 example, 0 failures"
147  
-    And the stdout should contain "should have 7 fingers"
  148
+    And the stdout should contain "has 7 fingers"
148 149
 
149 150
   Scenario: with multiple args
150 151
     Given a file named "matcher_with_multiple_args_spec.rb" with:
151 152
       """
152 153
       require 'rspec/expectations'
153  
-
154 154
       RSpec::Matchers.define :be_the_sum_of do |a,b,c,d|
155 155
         match do |sum|
156 156
           a + b + c + d == sum
@@ -164,7 +164,7 @@ Feature: define matcher
164 164
     When I run `rspec ./matcher_with_multiple_args_spec.rb --format documentation`
165 165
     Then the exit status should be 0
166 166
     And the stdout should contain "1 example, 0 failures"
167  
-    And the stdout should contain "should be the sum of 1, 2, 3, and 4"
  167
+    And the stdout should contain "is the sum of 1, 2, 3, and 4"
168 168
 
169 169
   Scenario: with helper methods
170 170
     Given a file named "matcher_with_internal_helper_spec.rb" with:
4  features/custom_matchers/define_matcher_with_fluent_interface.feature
... ...
@@ -1,7 +1,7 @@
1 1
 Feature: define matcher with fluent interface
2 2
 
3 3
   Use the chain() method to define matchers with a fluent interface.
4  
-  
  4
+
5 5
   Scenario: chained method with argumetn
6 6
     Given a file named "between_spec.rb" with:
7 7
       """
@@ -21,4 +21,4 @@ Feature: define matcher with fluent interface
21 21
       """
22 22
     When I run `rspec between_spec.rb --format documentation`
23 23
     Then the output should contain "1 example, 0 failures"
24  
-    And  the output should contain "should be bigger than 4"
  24
+    And  the output should contain "is bigger than 4"
14  features/implicit_docstrings.feature
@@ -20,9 +20,9 @@ Feature: implicit docstrings
20 20
 
21 21
     When I run `rspec ./implicit_docstrings_spec.rb -fdoc`
22 22
 
23  
-    Then the output should contain "should be < 5"
24  
-    And the output should contain "should include 2"
25  
-    And the output should contain "should respond to #size"
  23
+    Then the output should contain "is < 5"
  24
+    And the output should contain "includes 2"
  25
+    And the output should contain "responds to #size"
26 26
 
27 27
   Scenario: run failing examples
28 28
     Given a file named "failing_implicit_docstrings_spec.rb" with:
@@ -46,7 +46,7 @@ Feature: implicit docstrings
46 46
 
47 47
     When I run `rspec ./failing_implicit_docstrings_spec.rb -fdoc`
48 48
 
49  
-    Then the output should contain "should equal 2"
50  
-    And the output should contain "should be > 5"
51  
-    And the output should contain "should include 4"
52  
-    And the output should contain "should not respond to #size"
  49
+    Then the output should contain "equals 2"
  50
+    And the output should contain "is > 5"
  51
+    And the output should contain "includes 4"
  52
+    And the output should contain "does not respond to #size"
3  lib/rspec/expectations.rb
... ...
@@ -1,3 +1,4 @@
  1
+require 'rspec/core'
1 2
 require 'rspec/expectations/extensions'
2 3
 require 'rspec/matchers'
3 4
 require 'rspec/expectations/expectation_target'
@@ -37,7 +38,7 @@ module RSpec
37 38
   # `eq.failure_message_for_should_not`.
38 39
   #
39 40
   # rspec-expectations ships with a standard set of useful matchers, and writing
40  
-  # your own matchers is quite simple. 
  41
+  # your own matchers is quite simple.
41 42
   #
42 43
   # See [RSpec::Matchers](../RSpec/Matchers) for more information about the
43 44
   # built-in matchers that ship with rspec-expectations, and how to write your
22  lib/rspec/matchers.rb
@@ -93,7 +93,11 @@ module RSpec
93 93
   #         # generate and return the appropriate string.
94 94
   #       end
95 95
   #
96  
-  #       description do
  96
+  #       docstring_for_should do
  97
+  #         # generate and return the appropriate string.
  98
+  #       end
  99
+  #
  100
+  #       docstring_for_should_not do
97 101
   #         # generate and return the appropriate string.
98 102
   #       end
99 103
   #     end
@@ -214,7 +218,7 @@ def be_nil
214 218
     #
215 219
     # Given true, false, or nil, will pass if actual value is true, false or
216 220
     # nil (respectively). Given no args means the caller should satisfy an if
217  
-    # condition (to be or not to be). 
  221
+    # condition (to be or not to be).
218 222
     #
219 223
     # Predicates are any Ruby method that ends in a "?" and returns true or
220 224
     # false.  Given be_ followed by arbitrary_predicate (without the "?"),
@@ -246,7 +250,7 @@ def be_a(klass)
246 250
     def be_an_instance_of(expected)
247 251
       BuiltIn::BeAnInstanceOf.new(expected)
248 252
     end
249  
-    
  253
+
250 254
     alias_method :be_instance_of, :be_an_instance_of
251 255
 
252 256
     # Passes if actual.kind_of?(expected)
@@ -288,20 +292,20 @@ def be_within(delta)
288 292
     # @example
289 293
     #
290 294
     #   lambda {
291  
-    #     team.add_player(player) 
  295
+    #     team.add_player(player)
292 296
     #   }.should change(roster, :count)
293 297
     #
294 298
     #   lambda {
295  
-    #     team.add_player(player) 
  299
+    #     team.add_player(player)
296 300
     #   }.should change(roster, :count).by(1)
297 301
     #
298 302
     #   lambda {
299  
-    #     team.add_player(player) 
  303
+    #     team.add_player(player)
300 304
     #   }.should change(roster, :count).by_at_least(1)
301 305
     #
302 306
     #   lambda {
303 307
     #     team.add_player(player)
304  
-    #   }.should change(roster, :count).by_at_most(1)    
  308
+    #   }.should change(roster, :count).by_at_most(1)
305 309
     #
306 310
     #   string = "string"
307 311
     #   lambda {
@@ -311,7 +315,7 @@ def be_within(delta)
311 315
     #   lambda {
312 316
     #     person.happy_birthday
313 317
     #   }.should change(person, :birthday).from(32).to(33)
314  
-    #       
  318
+    #
315 319
     #   lambda {
316 320
     #     employee.develop_great_new_social_networking_app
317 321
     #   }.should change(employee, :title).from("Mail Clerk").to("CEO")
@@ -523,7 +527,7 @@ def raise_error(error=Exception, message=nil, &block)
523 527
     # provided. Names can be Strings or Symbols.
524 528
     #
525 529
     # @example
526  
-    # 
  530
+    #
527 531
     def respond_to(*names)
528 532
       BuiltIn::RespondTo.new(*names)
529 533
     end
48  lib/rspec/matchers/built_in/be.rb
@@ -15,6 +15,14 @@ def failure_message_for_should
15 15
         def failure_message_for_should_not
16 16
           "expected: non-true value\n     got: #{actual.inspect}"
17 17
         end
  18
+
  19
+        def docstring_for_should
  20
+          "is true"
  21
+        end
  22
+
  23
+        def docstring_for_should_not
  24
+          "is not true"
  25
+        end
18 26
       end
19 27
 
20 28
       class BeFalse < BaseMatcher
@@ -29,6 +37,14 @@ def failure_message_for_should
29 37
         def failure_message_for_should_not
30 38
           "expected: non-false value\n     got: #{actual.inspect}"
31 39
         end
  40
+
  41
+        def docstring_for_should
  42
+          "is false"
  43
+        end
  44
+
  45
+        def docstring_for_should_not
  46
+          "is not false"
  47
+        end
32 48
       end
33 49
 
34 50
       class BeNil < BaseMatcher
@@ -43,6 +59,14 @@ def failure_message_for_should
43 59
         def failure_message_for_should_not
44 60
           "expected: not nil\n     got: nil"
45 61
         end
  62
+
  63
+        def docstring_for_should
  64
+          "is nil"
  65
+        end
  66
+
  67
+        def docstring_for_should_not
  68
+          "is not nil"
  69
+        end
46 70
       end
47 71
 
48 72
       class Be < BaseMatcher
@@ -62,6 +86,14 @@ def failure_message_for_should_not
62 86
           "expected #{@actual.inspect} to evaluate to false"
63 87
         end
64 88
 
  89
+        def docstring_for_should
  90
+          "is"
  91
+        end
  92
+
  93
+        def docstring_for_should_not
  94
+          "is not"
  95
+        end
  96
+
65 97
         [:==, :<, :<=, :>=, :>, :===].each do |operator|
66 98
           define_method operator do |operand|
67 99
             BeComparedTo.new(operand, operator)
@@ -117,8 +149,12 @@ def failure_message_for_should_not
117 149
                             "It might be more clearly expressed in the positive?")
118 150
         end
119 151
 
120  
-        def description
121  
-          "be #{@operator} #{expected_to_sentence}#{args_to_sentence}"
  152
+        def docstring_for_should
  153
+          "is #{@operator} #{expected_to_sentence}#{args_to_sentence}"
  154
+        end
  155
+
  156
+        def docstring_for_should_not
  157
+          "is not #{@operator} #{expected_to_sentence}#{args_to_sentence}"
122 158
         end
123 159
       end
124 160
 
@@ -152,8 +188,12 @@ def failure_message_for_should_not
152 188
           "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}"
153 189
         end
154 190
 
155  
-        def description
156  
-          "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
  191
+        def docstring_for_should
  192
+          "is #{expected_to_sentence}#{args_to_sentence}"
  193
+        end
  194
+
  195
+        def docstring_for_should_not
  196
+          "is not #{expected_to_sentence}#{args_to_sentence}"
157 197
         end
158 198
 
159 199
         private
18  lib/rspec/matchers/built_in/be_within.rb
@@ -8,7 +8,7 @@ def initialize(delta)
8 8
 
9 9
         def matches?(actual)
10 10
           @actual = actual
11  
-          raise needs_expected     unless defined? @expected 
  11
+          raise needs_expected     unless defined? @expected
12 12
           raise needs_subtractable unless @actual.respond_to? :-
13 13
           (@actual - @expected).abs <= @delta
14 14
         end
@@ -20,19 +20,27 @@ def of(expected)
20 20
         end
21 21
 
22 22
         def failure_message_for_should
23  
-          "expected #{@actual} to #{description}"
  23
+          "expected #{@actual} to be #{docstring}"
24 24
         end
25 25
 
26 26
         def failure_message_for_should_not
27  
-          "expected #{@actual} not to #{description}"
  27
+          "expected #{@actual} not to be #{docstring}"
28 28
         end
29 29
 
30  
-        def description
31  
-          "be within #{@delta} of #{@expected}"
  30
+        def docstring_for_should
  31
+          "is #{docstring}"
  32
+        end
  33
+
  34
+        def docstring_for_should_not
  35
+          "is not #{docstring}"
32 36
         end
33 37
 
34 38
         private
35 39
 
  40
+        def docstring
  41
+          "within #{@delta} of #{@expected}"
  42
+        end
  43
+
36 44
         def needs_subtractable
37 45
           ArgumentError.new "The actual value (#{@actual.inspect}) must respond to `-`"
38 46
         end
10  lib/rspec/matchers/built_in/change.rb
@@ -72,7 +72,7 @@ def by_at_least(minimum)
72 72
         def by_at_most(maximum)
73 73
           @maximum = maximum
74 74
           self
75  
-        end      
  75
+        end
76 76
 
77 77
         def to(to)
78 78
           @eval_after = true
@@ -86,8 +86,12 @@ def from (before)
86 86
           self
87 87
         end
88 88
 
89  
-        def description
90  
-          "change ##{message}"
  89
+        def docstring_for_should
  90
+          "changes ##{message}"
  91
+        end
  92
+
  93
+        def docstring_for_should_not
  94
+          "does not change ##{message}"
91 95
         end
92 96
 
93 97
         private
9  lib/rspec/matchers/built_in/eq.rb
@@ -14,9 +14,16 @@ def failure_message_for_should_not
14 14
           "\nexpected: value != #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using ==)\n"
15 15
         end
16 16
 
  17
+        def docstring_for_should
  18
+          "eq #{expected.inspect}"
  19
+        end
  20
+
  21
+        def docstring_for_should_not
  22
+          "does not eq #{expected.inspect}"
  23
+        end
  24
+
17 25
         def diffable?; true; end
18 26
       end
19 27
     end
20 28
   end
21 29
 end
22  
-
8  lib/rspec/matchers/built_in/eql.rb
@@ -14,6 +14,14 @@ def failure_message_for_should_not
14 14
           "\nexpected: value != #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using eql?)\n"
15 15
         end
16 16
 
  17
+        def docstring_for_should
  18
+          "eql #{expected.inspect}"
  19
+        end
  20
+
  21
+        def docstring_for_should_not
  22
+          "does not eql #{expected.inspect}"
  23
+        end
  24
+
17 25
         def diffable?
18 26
           true
19 27
         end
8  lib/rspec/matchers/built_in/equal.rb
@@ -31,6 +31,14 @@ def failure_message_for_should_not
31 31
 MESSAGE
32 32
         end
33 33
 
  34
+        def docstring_for_should
  35
+          "equals #{expected.inspect}"
  36
+        end
  37
+
  38
+        def docstring_for_should_not
  39
+          "does not equal #{expected.inspect}"
  40
+        end
  41
+
34 42
         def diffable?; true; end
35 43
 
36 44
         private
12  lib/rspec/matchers/built_in/has.rb
@@ -19,12 +19,20 @@ def failure_message_for_should_not
19 19
           "expected ##{predicate(@expected)}#{failure_message_args_description} to return false, got true"
20 20
         end
21 21
 
22  
-        def description
23  
-          [method_description(@expected), args_description].compact.join(' ')
  22
+        def docstring_for_should
  23
+          docstring.sub(/have/, "has")
  24
+        end
  25
+
  26
+        def docstring_for_should_not
  27
+          "not #{docstring}"
24 28
         end
25 29
 
26 30
         private
27 31
 
  32
+        def docstring
  33
+          [method_description(@expected), args_description].compact.join(' ')
  34
+        end
  35
+
28 36
         def predicate(sym)
29 37
           "#{sym.to_s.sub("have_","has_")}?".to_sym
30 38
         end
8  lib/rspec/matchers/built_in/have.rb
@@ -79,8 +79,12 @@ def failure_message_for_should_not
79 79
           end
80 80
         end
81 81
 
82  
-        def description
83  
-          "have #{relative_expectation} #{@collection_name}"
  82
+        def docstring_for_should
  83
+          "has #{relative_expectation} #{@collection_name}"
  84
+        end
  85
+
  86
+        def docstring_for_should_not
  87
+          "does not have #{relative_expectation} #{@collection_name}"
84 88
         end
85 89
 
86 90
         def respond_to?(m)
8  lib/rspec/matchers/built_in/include.rb
@@ -16,8 +16,12 @@ def does_not_match?(actual)
16 16
           perform_match(:none?, :any?, @actual, @expected)
17 17
         end
18 18
 
19  
-        def description
20  
-          "include#{expected_to_sentence}"
  19
+        def docstring_for_should
  20
+          "includes#{expected_to_sentence}"
  21
+        end
  22
+
  23
+        def docstring_for_should_not
  24
+          "does not include#{expected_to_sentence}"
21 25
         end
22 26
 
23 27
         def diffable?
9  lib/rspec/matchers/built_in/match.rb
@@ -2,10 +2,17 @@ module RSpec
2 2
   module Matchers
3 3
     module BuiltIn
4 4
       class Match < BaseMatcher
5  
-
6 5
         def match(expected, actual)
7 6
           actual.match expected
8 7
         end
  8
+
  9
+        def docstring_for_should
  10
+          "matches #{expected.inspect}"
  11
+        end
  12
+
  13
+        def docstring_for_should_not
  14
+          "does not match #{expected.inspect}"
  15
+        end
9 16
       end
10 17
     end
11 18
   end
8  lib/rspec/matchers/built_in/match_array.rb
@@ -20,8 +20,12 @@ def failure_message_for_should_not
20 20
           "Matcher does not support should_not"
21 21
         end
22 22
 
23  
-        def description
24  
-          "contain exactly #{_pretty_print(expected)}"
  23
+        def docstring_for_should
  24
+          "contains exactly #{_pretty_print(@expected)}"
  25
+        end
  26
+
  27
+        def docstring_for_should_not
  28
+          "does not contain exactly #{_pretty_print(@expected)}"
25 29
         end
26 30
 
27 31
         private
8  lib/rspec/matchers/built_in/raise_error.rb
@@ -70,8 +70,12 @@ def failure_message_for_should_not
70 70
           "expected no #{expected_error}#{given_error}"
71 71
         end
72 72
 
73  
-        def description
74  
-          "raise #{expected_error}"
  73
+        def docstring_for_should
  74
+          "raises #{expected_error}"
  75
+        end
  76
+
  77
+        def docstring_for_should_not
  78
+          "does not raise #{expected_error}"
75 79
         end
76 80
 
77 81
         private
8  lib/rspec/matchers/built_in/respond_to.rb
@@ -24,8 +24,12 @@ def failure_message_for_should_not
24 24
           failure_message_for_should.sub(/to respond to/, 'not to respond to')
25 25
         end
26 26
 
27  
-        def description
28  
-          "respond to #{pp_names}#{with_arity}"
  27
+        def docstring_for_should
  28
+          "responds to #{pp_names}#{with_arity}"
  29
+        end
  30
+
  31
+        def docstring_for_should_not
  32
+          "does not respond to #{pp_names}#{with_arity}"
29 33
         end
30 34
 
31 35
         def with(n)
8  lib/rspec/matchers/built_in/satisfy.rb
@@ -21,8 +21,12 @@ def failure_message_for_should_not
21 21
           "expected #{@actual} not to satisfy block"
22 22
         end
23 23
 
24  
-        def description
25  
-          "satisfy block"
  24
+        def docstring_for_should
  25
+          "satisfies block"
  26
+        end
  27
+
  28
+        def docstring_for_should_not
  29
+          "does not satisfy block"
26 30
         end
27 31
       end
28 32
     end
8  lib/rspec/matchers/built_in/throw_symbol.rb
@@ -61,8 +61,12 @@ def failure_message_for_should_not
61 61
           "expected #{expected('no Symbol')}#{' not' if @expected_symbol} to be thrown, got #{caught}"
62 62
         end
63 63
 
64  
-        def description
65  
-          "throw #{expected}"
  64
+        def docstring_for_should
  65
+          "throws #{expected}"
  66
+        end
  67
+
  68
+        def docstring_for_should_not
  69
+          "does not throw #{expected}"
66 70
         end
67 71
 
68 72
         private
15  lib/rspec/matchers/generated_descriptions.rb
@@ -11,13 +11,22 @@ def self.clear_generated_description
11 11
 
12 12
     def self.generated_description
13 13
       return nil if last_should.nil?
14  
-      "#{last_should.to_s.gsub('_',' ')} #{last_description}"
  14
+      mode = last_should.to_s =~ /not/ ? :negative : :positive
  15
+      if mode == :positive && last_matcher.respond_to?(:docstring_for_should)
  16
+        last_matcher.docstring_for_should
  17
+      elsif mode == :negative && last_matcher.respond_to?(:docstring_for_should_not)
  18
+        last_matcher.docstring_for_should_not
  19
+      elsif last_matcher.respond_to?(:description)
  20
+        "#{last_should.to_s.gsub('_',' ')} #{last_matcher.description}"
  21
+      else
  22
+        no_description_message
  23
+      end
15 24
     end
16 25
 
17 26
   private
18 27
 
19  
-    def self.last_description
20  
-      last_matcher.respond_to?(:description) ? last_matcher.description : <<-MESSAGE
  28
+    def self.no_description_message
  29
+      return <<-MESSAGE
21 30
 When you call a matcher in an example without a String, like this:
22 31
 
23 32
 specify { object.should matcher }
17  lib/rspec/matchers/matcher.rb
@@ -159,7 +159,6 @@ def failure_message_for_should_not(&block)
159 159
           cache_or_call_cached(:failure_message_for_should_not, &block)
160 160
         end
161 161
 
162  
-
163 162
         # Customize the description to use for one-liners.  Only use this when
164 163
         # the description generated by default doesn't suit your needs.
165 164
         #
@@ -176,6 +175,14 @@ def description(&block)
176 175
           cache_or_call_cached(:description, &block)
177 176
         end
178 177
 
  178
+        def docstring_for_should(&block)
  179
+          cache_or_call_cached(:docstring_for_should, &block)
  180
+        end
  181
+
  182
+        def docstring_for_should_not(&block)
  183
+          cache_or_call_cached(:docstring_for_should_not, &block)
  184
+        end
  185
+
179 186
         # Tells the matcher to diff the actual and expected values in the failure
180 187
         # message.
181 188
         def diffable
@@ -280,6 +287,14 @@ def default_description
280 287
           "#{name_to_sentence}#{expected_to_sentence}"
281 288
         end
282 289
 
  290
+        def default_docstring_for_should
  291
+          default_description.sub(/^be/, 'is').sub(/^have/, 'has')
  292
+        end
  293
+
  294
+        def default_docstring_for_should_not
  295
+          default_description.sub(/^be/, 'is not').sub(/^have/, 'does not have')
  296
+        end
  297
+
283 298
         def default_failure_message_for_should
284 299
           "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"
285 300
         end
14  lib/rspec/matchers/operator_matcher.rb
@@ -47,12 +47,20 @@ def fail_with_message(message)
47 47
         RSpec::Expectations.fail_with(message, @expected, @actual)
48 48
       end
49 49
 
50  
-      def description
51  
-        "#{@operator} #{@expected.inspect}"
  50
+      def docstring_for_should
  51
+        docstring
  52
+      end
  53
+
  54
+      def docstring_for_should_not
  55
+        "does not #{docstring}"
52 56
       end
53 57
 
54 58
       private
55 59
 
  60
+      def docstring
  61
+        "#{@operator} #{@expected.inspect}"
  62
+      end
  63
+
56 64
       def eval_match(actual, operator, expected)
57 65
         ::RSpec::Matchers.last_matcher = self
58 66
         @operator, @expected = operator, expected
@@ -66,7 +74,7 @@ def __delegate_operator(actual, operator, expected)
66 74
           if actual.__send__(operator, expected)
67 75
             true
68 76
           elsif ['==','===', '=~'].include?(operator)
69  
-            fail_with_message("expected: #{expected.inspect}\n     got: #{actual.inspect} (using #{operator})") 
  77
+            fail_with_message("expected: #{expected.inspect}\n     got: #{actual.inspect} (using #{operator})")
70 78
           else
71 79
             fail_with_message("expected: #{operator} #{expected.inspect}\n     got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
72 80
           end
33  spec/rspec/matchers/be_spec.rb
... ...
@@ -1,6 +1,6 @@
1 1
 require 'spec_helper'
2 2
 
3  
-describe "should be_predicate" do  
  3
+describe "should be_predicate" do
4 4
   it "passes when actual returns true for :predicate?" do
5 5
     actual = stub("actual", :happy? => true)
6 6
     actual.should be_happy
@@ -17,20 +17,20 @@
17 17
       actual.should be_happy
18 18
     }.should fail_with("expected happy? to return true, got false")
19 19
   end
20  
-  
  20
+
21 21
   it "fails when actual returns false for :predicate?" do
22 22
     actual = stub("actual", :happy? => nil)
23 23
     lambda {
24 24
       actual.should be_happy
25 25
     }.should fail_with("expected happy? to return true, got nil")
26 26
   end
27  
-  
  27
+
28 28
   it "fails when actual does not respond to :predicate?" do
29 29
     lambda {
30 30
       Object.new.should be_happy
31 31
     }.should raise_error(NameError, /happy\?/)
32 32
   end
33  
-  
  33
+
34 34
   it "fails on error other than NameError" do
35 35
     actual = stub("actual")
36 36
     actual.should_receive(:foo?).and_raise("aaaah")
@@ -38,7 +38,7 @@
38 38
       actual.should be_foo
39 39
     }.should raise_error(/aaaah/)
40 40
   end
41  
-  
  41
+
42 42
   it "fails on error other than NameError (with the present tense predicate)" do
43 43
     actual = Object.new
44 44
     actual.should_receive(:foos?).and_raise("aaaah")
@@ -53,12 +53,12 @@
53 53
     actual = stub("actual", :happy? => false)
54 54
     actual.should_not be_happy
55 55
   end
56  
-  
  56
+
57 57
   it "passes when actual returns nil for :sym?" do
58 58
     actual = stub("actual", :happy? => nil)
59 59
     actual.should_not be_happy
60 60
   end
61  
-  
  61
+
62 62
   it "fails when actual returns true for :sym?" do
63 63
     actual = stub("actual", :happy? => true)
64 64
     lambda {
@@ -87,7 +87,7 @@
87 87
       actual.should be_older_than(3)
88 88
     }.should fail_with("expected older_than?(3) to return true, got false")
89 89
   end
90  
-  
  90
+
91 91
   it "fails when actual does not respond to :predicate?" do
92 92
     lambda {
93 93
       Object.new.should be_older_than(3)
@@ -101,7 +101,7 @@
101 101
     actual.should_receive(:older_than?).with(3).and_return(false)
102 102
     actual.should_not be_older_than(3)
103 103
   end
104  
-  
  104
+
105 105
   it "fails when actual returns true for :predicate?(*args)" do
106 106
     actual = mock("actual")
107 107
     actual.should_receive(:older_than?).with(3).and_return(true)
@@ -291,7 +291,7 @@
291 291
   end
292 292
 
293 293
   it "describes itself" do
294  
-    be.<(4).description.should == "be < 4"
  294
+    be.<(4).docstring_for_should.should eq "is < 4"
295 295
   end
296 296
 end
297 297
 
@@ -370,7 +370,7 @@
370 370
   end
371 371
 
372 372
   it "describes itself" do
373  
-    be.description.should == "be"
  373
+    be.description.should eq "be"
374 374
   end
375 375
 end
376 376
 
@@ -401,10 +401,10 @@
401 401
 
402 402
 describe "'should be' with operator" do
403 403
   it "includes 'be' in the description" do
404  
-    (be > 6).description.should =~ /be > 6/
405  
-    (be >= 6).description.should =~ /be >= 6/
406  
-    (be <= 6).description.should =~ /be <= 6/
407  
-    (be < 6).description.should =~ /be < 6/
  404
+    (be > 6).docstring_for_should.should =~ /is > 6/
  405
+    (be >= 6).docstring_for_should.should =~ /is >= 6/
  406
+    (be <= 6).docstring_for_should.should =~ /is <= 6/
  407
+    (be < 6).docstring_for_should.should =~ /is < 6/
408 408
   end
409 409
 end
410 410
 
@@ -444,9 +444,8 @@ def large?
444 444
   it "passes when direct class matches" do
445 445
     5.should be_an_instance_of(Fixnum)
446 446
   end
447  
-  
  447
+
448 448
   it "fails when class is higher up hierarchy" do
449 449
     5.should_not be_an_instance_of(Numeric)
450 450
   end
451 451
 end
452  
-
5  spec/rspec/matchers/be_within_spec.rb
@@ -57,10 +57,11 @@ module Matchers
57 57
         Time.now.should be_within(0.1).of(Time.now)
58 58
       end
59 59
 
60  
-      it "provides a description" do
  60
+      it "provides docstrings" do
61 61
         matcher = be_within(0.5).of(5.0)
62 62
         matcher.matches?(5.1)
63  
-        matcher.description.should == "be within 0.5 of 5.0"
  63
+        matcher.docstring_for_should.should eq "is within 0.5 of 5.0"
  64
+        matcher.docstring_for_should_not.should eq "is not within 0.5 of 5.0"
64 65
       end
65 66
 
66 67
       it "raises an error if no expected value is given" do
50  spec/rspec/matchers/change_spec.rb
@@ -22,9 +22,10 @@ class SomethingExpected
22 22
         expect {}.to change(@instance, :some_value)
23 23
       end.to fail_with("some_value should have changed, but is still 5")
24 24
     end
25  
-    
26  
-    it "provides a #description" do
27  
-      change(@instance, :some_value).description.should == "change #some_value"
  25
+
  26
+    it "provides docstrings" do
  27
+      change(@instance, :some_value).docstring_for_should.should eq "changes #some_value"
  28
+      change(@instance, :some_value).docstring_for_should_not.should eq "does not change #some_value"
28 29
     end
29 30
   end
30 31
 
@@ -173,15 +174,16 @@ def ==(other)
173 174
       expect {}.to change{ @instance.some_value }
174 175
     end.to fail_with("result should have changed, but is still 5")
175 176
   end
176  
-  
  177
+
177 178
   it "warns if passed a block using do/end instead of {}" do
178 179
     expect do
179 180
       expect {}.to change do; end
180 181
     end.to raise_error(SyntaxError, /block passed to should or should_not/)
181 182
   end
182  
-  
183  
-  it "provides a #description" do
184  
-    change { @instance.some_value }.description.should == "change #result"
  183
+
  184
+  it "provides docstrings" do
  185
+    change { @instance.some_value }.docstring_for_should.should eq "changes #result"
  186
+    change { @instance.some_value }.docstring_for_should_not.should eq "does not change #result"
185 187
   end
186 188
 end
187 189
 
@@ -200,7 +202,7 @@ def ==(other)
200 202
       expect {@instance.some_value = 6}.to_not change { @instance.some_value }
201 203
     end.to fail_with("result should not have changed, but did change from 5 to 6")
202 204
   end
203  
-  
  205
+
204 206
   it "warns if passed a block using do/end instead of {}" do
205 207
     expect do
206 208
       expect {}.to_not change do; end
@@ -267,10 +269,10 @@ def ==(other)
267 269
   it "passes when attribute is changed by greater than the expected amount" do
268 270
     expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(1)
269 271
   end
270  
-  
  272
+
271 273
   it "passes when attribute is changed by the expected amount" do
272 274
     expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(2)
273  
-  end  
  275
+  end
274 276
 
275 277
   it "fails when the attribute is changed by less than the expected amount" do
276 278
     expect do
@@ -289,10 +291,10 @@ def ==(other)
289 291
   it "passes when attribute is changed by greater than expected amount" do
290 292
     expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(1)
291 293
   end
292  
-  
  294
+
293 295
   it "passes when attribute is changed by the expected amount" do
294 296
     expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(2)
295  
-  end  
  297
+  end
296 298
 
297 299
   it "fails when the attribute is changed by less than the unexpected amount" do
298 300
     expect do
@@ -311,10 +313,10 @@ def ==(other)
311 313
   it "passes when attribute is changed by less than the expected amount" do
312 314
     expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(3)
313 315
   end
314  
-  
  316
+
315 317
   it "passes when attribute is changed by the expected amount" do
316 318
     expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(2)
317  
-  end  
  319
+  end
318 320
 
319 321
   it "fails when the attribute is changed by greater than the expected amount" do
320 322
     expect do
@@ -333,10 +335,10 @@ def ==(other)
333 335
   it "passes when attribute is changed by less than expected amount" do
334 336
     expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(3)
335 337
   end
336  
-  
  338
+
337 339
   it "passes when attribute is changed by the expected amount" do
338 340
     expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(2)
339  
-  end  
  341
+  end
340 342
 
341 343
   it "fails when the attribute is changed by greater than the unexpected amount" do
342 344
     expect do
@@ -415,7 +417,7 @@ def ==(other)
415 417
       @instance = SomethingExpected.new
416 418
       @instance.some_value = true
417 419
     end
418  
-    
  420
+
419 421
     it "passes when attribute is == to expected value after executing block" do
420 422
       expect { @instance.some_value = false }.to change(@instance, :some_value).to(false)
421 423
     end
@@ -431,7 +433,7 @@ def ==(other)
431 433
       @instance = SomethingExpected.new
432 434
       @instance.some_value = 'string'
433 435
     end
434  
-    
  436
+
435 437
     it "passes when attribute is === to expected value after executing block" do
436 438
       expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat")
437 439
     end
@@ -455,7 +457,7 @@ def ==(other)
455 457
     @instance = SomethingExpected.new
456 458
     @instance.some_value = 'string'
457 459
   end
458  
-  
  460
+
459 461
   it "passes when attribute is === to expected value after executing block" do
460 462
     expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat")
461 463
   end
@@ -478,7 +480,7 @@ def ==(other)
478 480
     @instance = SomethingExpected.new
479 481
     @instance.some_value = 'string'
480 482
   end
481  
-  
  483
+
482 484
   it "passes when #to comes before #from" do
483 485
     expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat").from("string")
484 486
   end
@@ -486,13 +488,13 @@ def ==(other)
486 488
   it "passes when #from comes before #to" do
487 489
     expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("cat")
488 490
   end
489  
-  
  491
+
490 492
   it "shows the correct messaging when #after and #to are different" do
491 493
     expect do
492 494
       expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog")
493 495
     end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
494 496
   end
495  
-  
  497
+
496 498
   it "shows the correct messaging when #before and #from are different" do
497 499
     expect do
498 500
       expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("not_string").to("cat")
@@ -505,7 +507,7 @@ def ==(other)
505 507
     @instance = SomethingExpected.new
506 508
     @instance.some_value = 'string'
507 509
   end
508  
-  
  510
+
509 511
   it "passes when #to comes before #from" do
510 512
     expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat").from("string")
511 513
   end
@@ -520,7 +522,7 @@ def ==(other)
520 522
     @instance = SomethingExpected.new
521 523
     @instance.some_value = "string"
522 524
     def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end
523  
-    
  525
+
524 526
     expect {
525 527
       expect { @instance.some_value = "cat" }.to change(@instance, :some_value)
526 528
     }.to_not raise_error
93  spec/rspec/matchers/description_generation_spec.rb
... ...
@@ -1,79 +1,84 @@
1 1
 require 'spec_helper'
2 2
 
3  
-describe "Matchers should be able to generate their own descriptions" do
  3
+describe "Matchers generate their own descriptions" do
4 4
   after(:each) do
5 5
     RSpec::Matchers.clear_generated_description
6 6
   end
7 7
 
8  
-  it "should eq expected" do
9  
-    "this".should eq "this"
10  
-    RSpec::Matchers.generated_description.should eq "should eq \"this\""
  8
+  it "should == expected" do
  9
+    "this".should == "this"
  10
+    RSpec::Matchers.generated_description.should == "== \"this\""
11 11
   end
12 12
 
13  
-  it "should not eq expected" do
14  
-    "this".should_not eq "that"
15  
-    RSpec::Matchers.generated_description.should eq "should not eq \"that\""
  13
+  it "should not == expected" do
  14
+    "this".should_not == "that"
  15
+    RSpec::Matchers.generated_description.should == "does not == \"that\""
16 16
   end
17 17
 
18 18
   it "should be empty (arbitrary predicate)" do
19 19
     [].should be_empty
20  
-    RSpec::Matchers.generated_description.should eq "should be empty"
  20
+    RSpec::Matchers.generated_description.should == "is empty"
21 21
   end
22 22
 
23 23
   it "should not be empty (arbitrary predicate)" do
24 24
     [1].should_not be_empty
25  
-    RSpec::Matchers.generated_description.should eq "should not be empty"
  25
+    RSpec::Matchers.generated_description.should == "is not empty"
26 26
   end
27 27
 
28 28
   it "should be true" do
29 29
     true.should be_true
30  
-    RSpec::Matchers.generated_description.should eq "should be true"
  30
+    RSpec::Matchers.generated_description.should == "is true"
31 31
   end
32 32
 
33 33
   it "should be false" do
34 34
     false.should be_false
35  
-    RSpec::Matchers.generated_description.should eq "should be false"
  35
+    RSpec::Matchers.generated_description.should == "is false"
36 36
   end
37 37
 
38 38
   it "should be nil" do
39 39
     nil.should be_nil
40  
-    RSpec::Matchers.generated_description.should eq "should be nil"
  40
+    RSpec::Matchers.generated_description.should == "is nil"
41 41
   end
42 42
 
43 43
   it "should be > n" do
44 44
     5.should be > 3
45  
-    RSpec::Matchers.generated_description.should eq "should be > 3"
  45
+    RSpec::Matchers.generated_description.should == "is > 3"
46 46
   end
47 47
 
48 48
   it "should be predicate arg1, arg2 and arg3" do
49 49
     5.0.should be_between(0,10)
50  
-    RSpec::Matchers.generated_description.should eq "should be between 0 and 10"
  50
+    RSpec::Matchers.generated_description.should == "is between 0 and 10"
  51
+  end
  52
+
  53
+  it "should not be predicate arg1, arg2 and arg3" do
  54
+    5.0.should_not be_between(0, 1)
  55
+    RSpec::Matchers.generated_description.should == "is not between 0 and 1"
51 56
   end
52 57
 
53 58
   it "should equal" do
54 59
     expected = "expected"
55 60
     expected.should equal(expected)
56  
-    RSpec::Matchers.generated_description.should eq "should equal \"expected\""
  61
+    RSpec::Matchers.generated_description.should == "equals \"expected\""
57 62
   end
58 63
 
59 64
   it "should_not equal" do
60 65
     5.should_not equal(37)
61  
-    RSpec::Matchers.generated_description.should eq "should not equal 37"
  66
+    RSpec::Matchers.generated_description.should == "does not equal 37"
62 67
   end
63 68
 
64 69
   it "should eql" do
65 70
     "string".should eql("string")
66  
-    RSpec::Matchers.generated_description.should eq "should eql \"string\""
  71
+    RSpec::Matchers.generated_description.should == "eql \"string\""
67 72
   end
68 73
 
69 74
   it "should not eql" do
70 75
     "a".should_not eql(:a)
71  
-    RSpec::Matchers.generated_description.should eq "should not eql :a"
  76
+    RSpec::Matchers.generated_description.should == "does not eql :a"
72 77
   end
73 78
 
74 79
   it "should have_key" do
75 80
     {:a => "a"}.should have_key(:a)
76  
-    RSpec::Matchers.generated_description.should eq "should have key :a"
  81
+    RSpec::Matchers.generated_description.should == "has key :a"
77 82
   end
78 83
 
79 84
   it "should have_some_method" do
@@ -81,7 +86,7 @@
81 86
     def object.has_eyes_closed?; true; end
82 87
 
83 88
     object.should have_eyes_closed
84  
-    RSpec::Matchers.generated_description.should eq 'should have eyes closed'
  89
+    RSpec::Matchers.generated_description.should == 'has eyes closed'
85 90
   end
86 91
 
87 92
   it "should have_some_method(args*)" do
@@ -89,78 +94,88 @@ def object.has_eyes_closed?; true; end
89 94
     def object.has_taste_for?(*args); true; end
90 95
 
91 96
     object.should have_taste_for("wine", "cheese")
92  
-    RSpec::Matchers.generated_description.should eq 'should have taste for "wine", "cheese"'
  97
+    RSpec::Matchers.generated_description.should == 'has taste for "wine", "cheese"'
93 98
   end
94 99
 
95 100
   it "should have n items" do
96 101
     team.should have(3).players
97  
-    RSpec::Matchers.generated_description.should eq "should have 3 players"
  102
+    RSpec::Matchers.generated_description.should == "has 3 players"
98 103
   end
99 104
 
100 105
   it "should have at least n items" do
101 106
     team.should have_at_least(2).players
102  
-    RSpec::Matchers.generated_description.should eq "should have at least 2 players"
  107
+    RSpec::Matchers.generated_description.should == "has at least 2 players"
103 108
   end
104 109
 
105 110
   it "should have at most n items" do
106 111
     team.should have_at_most(4).players
107  
-    RSpec::Matchers.generated_description.should eq "should have at most 4 players"
  112
+    RSpec::Matchers.generated_description.should == "has at most 4 players"
108 113
   end
109 114
 
110 115
   it "should include" do
111 116
     [1,2,3].should include(3)
112  
-    RSpec::Matchers.generated_description.should eq "should include 3"
  117
+    RSpec::Matchers.generated_description.should == "includes 3"
113 118
   end
114 119
 
115 120
   it "array.should =~ [1,2,3]" do
116 121
     [1,2,3].should =~ [1,2,3]
117  
-    RSpec::Matchers.generated_description.should eq "should contain exactly 1, 2 and 3"
  122
+    RSpec::Matchers.generated_description.should == "contains exactly 1, 2 and 3"
118 123
   end
119 124
 
120 125
   it "should match" do
121 126
     "this string".should match(/this string/)
122  
-    RSpec::Matchers.generated_description.should eq "should match /this string/"
  127
+    RSpec::Matchers.generated_description.should == "matches /this string/"
123 128
   end
124 129
 
125 130
   it "should raise_error" do
126 131
     lambda { raise }.should raise_error
127  
-    RSpec::Matchers.generated_description.should eq "should raise Exception"
  132
+    RSpec::Matchers.generated_description.should == "raises Exception"
128 133
   end
129 134
 
130 135
   it "should raise_error with type" do
131 136
     lambda { raise }.should raise_error(RuntimeError)
132  
-    RSpec::Matchers.generated_description.should eq "should raise RuntimeError"
  137
+    RSpec::Matchers.generated_description.should == "raises RuntimeError"
133 138
   end
134 139
 
135 140
   it "should raise_error with type and message" do
136 141
     lambda { raise "there was an error" }.should raise_error(RuntimeError, "there was an error")
137  
-    RSpec::Matchers.generated_description.should eq "should raise RuntimeError with \"there was an error\""
  142
+    RSpec::Matchers.generated_description.should == "raises RuntimeError with \"there was an error\""
  143
+  end
  144
+
  145
+  it "should not raise_error with type and message" do
  146
+    lambda { "Innocuous" }.should_not raise_error(RuntimeError, "there was an error")
  147
+    RSpec::Matchers.generated_description.should == "does not raise RuntimeError with \"there was an error\""
138 148
   end
139 149
 
140 150
   it "should respond_to" do
141 151
     [].should respond_to(:insert)
142  
-    RSpec::Matchers.generated_description.should eq "should respond to #insert"
  152
+    RSpec::Matchers.generated_description.should == "responds to #insert"
143 153
   end
144 154
 
145 155
   it "should throw symbol" do
146 156
     lambda { throw :what_a_mess }.should throw_symbol
147  
-    RSpec::Matchers.generated_description.should eq "should throw a Symbol"
  157
+    RSpec::Matchers.generated_description.should == "throws a Symbol"
148 158
   end
149 159
 
150 160
   it "should throw symbol (with named symbol)" do
151 161
     lambda { throw :what_a_mess }.should throw_symbol(:what_a_mess)
152  
-    RSpec::Matchers.generated_description.should eq "should throw :what_a_mess"
  162
+    RSpec::Matchers.generated_description.should == "throws :what_a_mess"
153 163
   end
154 164
 
155  
-  def team
156  
-    Class.new do
157  
-      def players
158  
-        [1,2,3]
159  
-      end
160  
-    end.new
  165
+  it "should == expected" do
  166
+    3.should == 3
  167
+    RSpec::Matchers.generated_description.should == "== 3"
161 168
   end
162 169
 end
163 170
 
  171
+def team
  172
+  Class.new do
  173
+    def players
  174
+      [1,2,3]
  175
+    end
  176
+  end.new
  177
+end
  178
+
164 179
 describe "a Matcher with no description" do
165 180
   def matcher
166 181
      Class.new do
5  spec/rspec/matchers/include_spec.rb
@@ -60,9 +60,10 @@
60 60
   end
61 61
 
62 62
   describe "should include(with, multiple, args)" do
63  
-    it "has a description" do
  63
+    it "has docstrings" do
64 64
       matcher = include("a")
65  
-      matcher.description.should eq("include \"a\"")
  65
+      matcher.docstring_for_should.should eq("includes \"a\"")
  66
+      matcher.docstring_for_should_not.should eq("does not include \"a\"")
66 67
     end
67 68
     context "for a string target" do
68 69
       it "passes if target includes all items" do
30  spec/rspec/matchers/respond_to_spec.rb
@@ -4,17 +4,16 @@
4 4
   it_behaves_like "an RSpec matcher", :valid_value => "s", :invalid_value => 5 do
5 5
     let(:matcher) { respond_to(:upcase) }
6 6
   end
7  
-  
  7
+
8 8
   it "passes if target responds to :sym" do
9 9
     Object.new.should respond_to(:methods)
10 10
   end
11  
-  
  11
+
12 12
   it "fails if target does not respond to :sym" do
13