Skip to content
This repository
Browse code

cleanup and add some rdoc

  • Loading branch information...
commit f6467431446aa822d20828a5854c9e31e939a369 1 parent b3832f5
David Chelimsky authored October 16, 2011
19  README.md
Source Rendered
@@ -3,21 +3,6 @@
3 3
 rspec-mocks provides a test-double framework for rspec including support
4 4
 for method stubs, fakes, and message expectations.
5 5
 
6  
-[![build status](http://travis-ci.org/rspec/rspec-mocks.png)](http://travis-ci.org/rspec/rspec-mocks)
7  
-
8  
-## Documentation
9  
-
10  
-The [Cucumber features](http://relishapp.com/rspec/rspec-mocks) are the
11  
-most comprehensive and up-to-date docs for end-users.
12  
-
13  
-The [RDoc](http://rubydoc.info/gems/rspec-mocks/2.3.0/frames) provides additional
14  
-information for contributors and/or extenders.
15  
-
16  
-All of the documentation is open source and a work in progress. If you find it
17  
-lacking or confusing, you can help improve it by submitting requests and
18  
-patches to the [rspec-mocks issue
19  
-tracker](https://github.com/rspec/rspec-mocks/issues).
20  
-
21 6
 ## Install
22 7
 
23 8
     gem install rspec       # for rspec-core, rspec-expectations, rspec-mocks
@@ -48,10 +33,6 @@ tracker](https://github.com/rspec/rspec-mocks/issues).
48 33
       end
49 34
     end
50 35
 
51  
-## Contribute
52  
-
53  
-See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
54  
-
55 36
 ## Also see
56 37
 
57 38
 * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
44  lib/rspec/mocks/argument_matchers.rb
@@ -138,48 +138,41 @@ def ==(actual)
138 138
         end
139 139
       end
140 140
 
141  
-      # :call-seq:
142  
-      #   object.should_receive(:message).with(any_args())
143  
-      #
144 141
       # Passes if object receives :message with any args at all. This is
145 142
       # really a more explicit variation of object.should_receive(:message)
  143
+      #
  144
+      # == Examples
  145
+      #   object.should_receive(:message).with(any_args())
146 146
       def any_args
147 147
         AnyArgsMatcher.new
148 148
       end
149 149
       
150  
-      # :call-seq:
151  
-      #   object.should_receive(:message).with(anything())
152  
-      #
153 150
       # Passes as long as there is an argument.
  151
+      #
  152
+      # == Examples
  153
+      #   object.should_receive(:message).with(anything())
154 154
       def anything
155 155
         AnyArgMatcher.new(nil)
156 156
       end
157 157
       
158  
-      # :call-seq:
159  
-      #   object.should_receive(:message).with(no_args)
160  
-      #
161 158
       # Passes if no arguments are passed along with the message
  159
+      #
  160
+      # == Examples
  161
+      #   object.should_receive(:message).with(no_args)
162 162
       def no_args
163 163
         NoArgsMatcher.new
164 164
       end
165 165
       
166  
-      # :call-seq:
167  
-      #   object.should_receive(:message).with(duck_type(:hello))
168  
-      #   object.should_receive(:message).with(duck_type(:hello, :goodbye))
169  
-      #
170 166
       # Passes if the argument responds to the specified messages.
171 167
       #
172 168
       # == Examples
173  
-      #
174  
-      #   array = []
175  
-      #   display = double('display')
176  
-      #   display.should_receive(:present_names).with(duck_type(:length, :each))
177  
-      #   => passes
  169
+      #   object.should_receive(:message).with(duck_type(:hello))
  170
+      #   object.should_receive(:message).with(duck_type(:hello, :goodbye))
178 171
       def duck_type(*args)
179 172
         DuckTypeMatcher.new(*args)
180 173
       end
181 174
 
182  
-      # :call-seq:
  175
+      # == Examples
183 176
       #   object.should_receive(:message).with(boolean())
184 177
       #
185 178
       # Passes if the argument is boolean.
@@ -187,22 +180,23 @@ def boolean
187 180
         BooleanMatcher.new(nil)
188 181
       end
189 182
       
190  
-      # :call-seq:
  183
+      # Passes if the argument is a hash that includes the specified key(s) or key/value
  184
+      # pairs. If the hash includes other keys, it will still pass.
  185
+      #
  186
+      # == Examples
191 187
       #   object.should_receive(:message).with(hash_including(:key => val))
192 188
       #   object.should_receive(:message).with(hash_including(:key))
193 189
       #   object.should_receive(:message).with(hash_including(:key, :key2 => val2))
194  
-      # Passes if the argument is a hash that includes the specified key(s) or key/value
195  
-      # pairs. If the hash includes other keys, it will still pass.
196 190
       def hash_including(*args)
197 191
         HashIncludingMatcher.new(anythingize_lonely_keys(*args))
198 192
       end
199 193
       
200  
-      # :call-seq:
  194
+      # Passes if the argument is a hash that doesn't include the specified key(s) or key/value
  195
+      #
  196
+      # == Examples
201 197
       #   object.should_receive(:message).with(hash_not_including(:key => val))
202 198
       #   object.should_receive(:message).with(hash_not_including(:key))
203 199
       #   object.should_receive(:message).with(hash_not_including(:key, :key2 => :val2))
204  
-      #
205  
-      # Passes if the argument is a hash that doesn't include the specified key(s) or key/value
206 200
       def hash_not_including(*args)
207 201
         HashNotIncludingMatcher.new(anythingize_lonely_keys(*args))
208 202
       end
11  lib/rspec/mocks/message_expectation.rb
@@ -63,10 +63,8 @@ def and_return(*values, &return_block)
63 63
         @return_block = block_given? ? return_block : lambda { value }
64 64
       end
65 65
       
66  
-      # :call-seq:
67  
-      #   and_raise()
68  
-      #   and_raise(Exception) #any exception class
69  
-      #   and_raise(exception) #any exception object
  66
+      # Tells the mock or stub to raise an exception when the message
  67
+      # is received.
70 68
       #
71 69
       # == Warning
72 70
       #
@@ -74,6 +72,11 @@ def and_return(*values, &return_block)
74 72
       # raise an instance of it, creating it with +new+. If the exception
75 73
       # class initializer requires any parameters, you must pass in an
76 74
       # instance and not the class.
  75
+      #
  76
+      # == Examples
  77
+      #   and_raise()
  78
+      #   and_raise(Exception) #any exception class
  79
+      #   and_raise(exception) #any exception object
77 80
       def and_raise(exception=Exception)
78 81
         @exception_to_raise = exception
79 82
       end
12  lib/rspec/mocks/methods.rb
@@ -24,15 +24,13 @@ def unstub(sym)
24 24
       alias_method :stub!, :stub
25 25
       alias_method :unstub!, :unstub
26 26
       
27  
-      # :call-seq:
28  
-      #   double.stub_chain("foo.bar") { :baz }
29  
-      #   double.stub_chain(:foo, :bar) { :baz }
30  
-      #
31 27
       # Stubs a chain of methods. Especially useful with fluent and/or
32 28
       # composable interfaces.
33 29
       #
34 30
       # == Examples
35 31
       #
  32
+      #   double.stub_chain("foo.bar") { :baz }
  33
+      #   double.stub_chain(:foo, :bar) { :baz }
36 34
       #   Article.stub_chain("recent.published") { [Article.new] }
37 35
       def stub_chain(*chain, &blk)
38 36
         chain, blk = format_chain(*chain, &blk)
@@ -50,15 +48,15 @@ def stub_chain(*chain, &blk)
50 48
         end
51 49
       end
52 50
       
53  
-      def received_message?(sym, *args, &block) #:nodoc:
  51
+      def received_message?(sym, *args, &block)
54 52
         __mock_proxy.received_message?(sym.to_sym, *args, &block)
55 53
       end
56 54
       
57  
-      def rspec_verify #:nodoc:
  55
+      def rspec_verify
58 56
         __mock_proxy.verify
59 57
       end
60 58
 
61  
-      def rspec_reset #:nodoc:
  59
+      def rspec_reset
62 60
         __mock_proxy.reset
63 61
       end
64 62
       
6  lib/rspec/mocks/proxy.rb
@@ -45,11 +45,11 @@ def as_null_object
45 45
         @object
46 46
       end
47 47
 
48  
-      def already_proxied_respond_to # :nodoc:
  48
+      def already_proxied_respond_to
49 49
         @already_proxied_respond_to = true
50 50
       end
51 51
 
52  
-      def already_proxied_respond_to? # :nodoc:
  52
+      def already_proxied_respond_to?
53 53
         @already_proxied_respond_to
54 54
       end
55 55
 
@@ -69,7 +69,7 @@ def remove_stub(method_name)
69 69
         method_double[method_name].remove_stub
70 70
       end
71 71
       
72  
-      def verify #:nodoc:
  72
+      def verify
73 73
         method_doubles.each {|d| d.verify}
74 74
       ensure
75 75
         reset
6  lib/rspec/mocks/version.rb
... ...
@@ -1,6 +1,6 @@
1  
-module RSpec # :nodoc:
2  
-  module Mocks # :nodoc:
3  
-    module Version # :nodoc:
  1
+module RSpec
  2
+  module Mocks
  3
+    module Version
4 4
       STRING = '2.7.0.rc1'
5 5
     end
6 6
   end

0 notes on commit f646743

Please sign in to comment.
Something went wrong with that request. Please try again.