From f6467431446aa822d20828a5854c9e31e939a369 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Sun, 16 Oct 2011 12:58:07 -0500 Subject: [PATCH] cleanup and add some rdoc --- README.md | 19 ----------- lib/rspec/mocks/argument_matchers.rb | 44 +++++++++++--------------- lib/rspec/mocks/message_expectation.rb | 11 ++++--- lib/rspec/mocks/methods.rb | 12 +++---- lib/rspec/mocks/proxy.rb | 6 ++-- lib/rspec/mocks/version.rb | 6 ++-- 6 files changed, 37 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 7f182c93b..4ae8806f9 100644 --- a/README.md +++ b/README.md @@ -3,21 +3,6 @@ rspec-mocks provides a test-double framework for rspec including support for method stubs, fakes, and message expectations. -[![build status](http://travis-ci.org/rspec/rspec-mocks.png)](http://travis-ci.org/rspec/rspec-mocks) - -## Documentation - -The [Cucumber features](http://relishapp.com/rspec/rspec-mocks) are the -most comprehensive and up-to-date docs for end-users. - -The [RDoc](http://rubydoc.info/gems/rspec-mocks/2.3.0/frames) provides additional -information for contributors and/or extenders. - -All of the documentation is open source and a work in progress. If you find it -lacking or confusing, you can help improve it by submitting requests and -patches to the [rspec-mocks issue -tracker](https://github.com/rspec/rspec-mocks/issues). - ## Install gem install rspec # for rspec-core, rspec-expectations, rspec-mocks @@ -48,10 +33,6 @@ tracker](https://github.com/rspec/rspec-mocks/issues). end end -## Contribute - -See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev) - ## Also see * [http://github.com/rspec/rspec](http://github.com/rspec/rspec) diff --git a/lib/rspec/mocks/argument_matchers.rb b/lib/rspec/mocks/argument_matchers.rb index c6386b147..09bf2467a 100644 --- a/lib/rspec/mocks/argument_matchers.rb +++ b/lib/rspec/mocks/argument_matchers.rb @@ -138,48 +138,41 @@ def ==(actual) end end - # :call-seq: - # object.should_receive(:message).with(any_args()) - # # Passes if object receives :message with any args at all. This is # really a more explicit variation of object.should_receive(:message) + # + # == Examples + # object.should_receive(:message).with(any_args()) def any_args AnyArgsMatcher.new end - # :call-seq: - # object.should_receive(:message).with(anything()) - # # Passes as long as there is an argument. + # + # == Examples + # object.should_receive(:message).with(anything()) def anything AnyArgMatcher.new(nil) end - # :call-seq: - # object.should_receive(:message).with(no_args) - # # Passes if no arguments are passed along with the message + # + # == Examples + # object.should_receive(:message).with(no_args) def no_args NoArgsMatcher.new end - # :call-seq: - # object.should_receive(:message).with(duck_type(:hello)) - # object.should_receive(:message).with(duck_type(:hello, :goodbye)) - # # Passes if the argument responds to the specified messages. # # == Examples - # - # array = [] - # display = double('display') - # display.should_receive(:present_names).with(duck_type(:length, :each)) - # => passes + # object.should_receive(:message).with(duck_type(:hello)) + # object.should_receive(:message).with(duck_type(:hello, :goodbye)) def duck_type(*args) DuckTypeMatcher.new(*args) end - # :call-seq: + # == Examples # object.should_receive(:message).with(boolean()) # # Passes if the argument is boolean. @@ -187,22 +180,23 @@ def boolean BooleanMatcher.new(nil) end - # :call-seq: + # Passes if the argument is a hash that includes the specified key(s) or key/value + # pairs. If the hash includes other keys, it will still pass. + # + # == Examples # object.should_receive(:message).with(hash_including(:key => val)) # object.should_receive(:message).with(hash_including(:key)) # object.should_receive(:message).with(hash_including(:key, :key2 => val2)) - # Passes if the argument is a hash that includes the specified key(s) or key/value - # pairs. If the hash includes other keys, it will still pass. def hash_including(*args) HashIncludingMatcher.new(anythingize_lonely_keys(*args)) end - # :call-seq: + # Passes if the argument is a hash that doesn't include the specified key(s) or key/value + # + # == Examples # object.should_receive(:message).with(hash_not_including(:key => val)) # object.should_receive(:message).with(hash_not_including(:key)) # object.should_receive(:message).with(hash_not_including(:key, :key2 => :val2)) - # - # Passes if the argument is a hash that doesn't include the specified key(s) or key/value def hash_not_including(*args) HashNotIncludingMatcher.new(anythingize_lonely_keys(*args)) end diff --git a/lib/rspec/mocks/message_expectation.rb b/lib/rspec/mocks/message_expectation.rb index f29ec89a8..e21831a51 100644 --- a/lib/rspec/mocks/message_expectation.rb +++ b/lib/rspec/mocks/message_expectation.rb @@ -63,10 +63,8 @@ def and_return(*values, &return_block) @return_block = block_given? ? return_block : lambda { value } end - # :call-seq: - # and_raise() - # and_raise(Exception) #any exception class - # and_raise(exception) #any exception object + # Tells the mock or stub to raise an exception when the message + # is received. # # == Warning # @@ -74,6 +72,11 @@ def and_return(*values, &return_block) # raise an instance of it, creating it with +new+. If the exception # class initializer requires any parameters, you must pass in an # instance and not the class. + # + # == Examples + # and_raise() + # and_raise(Exception) #any exception class + # and_raise(exception) #any exception object def and_raise(exception=Exception) @exception_to_raise = exception end diff --git a/lib/rspec/mocks/methods.rb b/lib/rspec/mocks/methods.rb index 86693508c..cb0ce9842 100644 --- a/lib/rspec/mocks/methods.rb +++ b/lib/rspec/mocks/methods.rb @@ -24,15 +24,13 @@ def unstub(sym) alias_method :stub!, :stub alias_method :unstub!, :unstub - # :call-seq: - # double.stub_chain("foo.bar") { :baz } - # double.stub_chain(:foo, :bar) { :baz } - # # Stubs a chain of methods. Especially useful with fluent and/or # composable interfaces. # # == Examples # + # double.stub_chain("foo.bar") { :baz } + # double.stub_chain(:foo, :bar) { :baz } # Article.stub_chain("recent.published") { [Article.new] } def stub_chain(*chain, &blk) chain, blk = format_chain(*chain, &blk) @@ -50,15 +48,15 @@ def stub_chain(*chain, &blk) end end - def received_message?(sym, *args, &block) #:nodoc: + def received_message?(sym, *args, &block) __mock_proxy.received_message?(sym.to_sym, *args, &block) end - def rspec_verify #:nodoc: + def rspec_verify __mock_proxy.verify end - def rspec_reset #:nodoc: + def rspec_reset __mock_proxy.reset end diff --git a/lib/rspec/mocks/proxy.rb b/lib/rspec/mocks/proxy.rb index 48275a592..f070eb16d 100644 --- a/lib/rspec/mocks/proxy.rb +++ b/lib/rspec/mocks/proxy.rb @@ -45,11 +45,11 @@ def as_null_object @object end - def already_proxied_respond_to # :nodoc: + def already_proxied_respond_to @already_proxied_respond_to = true end - def already_proxied_respond_to? # :nodoc: + def already_proxied_respond_to? @already_proxied_respond_to end @@ -69,7 +69,7 @@ def remove_stub(method_name) method_double[method_name].remove_stub end - def verify #:nodoc: + def verify method_doubles.each {|d| d.verify} ensure reset diff --git a/lib/rspec/mocks/version.rb b/lib/rspec/mocks/version.rb index 2c9239d96..0f834dc67 100644 --- a/lib/rspec/mocks/version.rb +++ b/lib/rspec/mocks/version.rb @@ -1,6 +1,6 @@ -module RSpec # :nodoc: - module Mocks # :nodoc: - module Version # :nodoc: +module RSpec + module Mocks + module Version STRING = '2.7.0.rc1' end end