Permalink
Browse files

cleanup and add some rdoc

  • Loading branch information...
1 parent 40d5ba9 commit 4638609046a120c86d48a0253b471db55a5fd441 @dchelimsky dchelimsky committed Oct 16, 2011
View
@@ -1,22 +1,7 @@
# RSpec Expectations
rspec-expectations adds `should` and `should_not` to every object and includes
-RSpec::Matchers, a library of standard matchers.
-
-[![build status](https://secure.travis-ci.org/rspec/rspec-expectations.png)](http://travis-ci.org/rspec/rspec-expectations)
-
-## Documentation
-
-The [Cucumber features](http://relishapp.com/rspec/rspec-expectations)
-are the most comprehensive and up-to-date docs for end-users.
-
-The [RDoc](http://rubydoc.info/gems/rspec-expectations/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-expectations issue
-tracker](https://github.com/rspec/rspec-expectations/issues).
+several standard matchers in RSpec::Matchers
## Install
@@ -32,10 +17,6 @@ Matchers are objects used to compose expectations:
In that example, `eq("this value")` returns a `Matcher` object that
compares the actual `result` to the expected `"this value"`.
-## 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)
@@ -1,14 +1,6 @@
module RSpec
module Matchers
- # :call-seq:
- # should be_close(expected, delta)
- # should_not be_close(expected, delta)
- #
- # Passes if actual == expected +/- delta
- #
- # == Example
- #
- # result.should be_close(3.0, 0.5)
+ # @deprecated use +be_within+ instead.
def be_close(expected, delta)
RSpec.deprecate("be_close(#{expected}, #{delta})", "be_within(#{delta}).of(#{expected})")
be_within(delta).of(expected)
@@ -1,14 +1,11 @@
module RSpec
module Matchers
- # :call-seq:
- # should be_within(delta).of(expected)
- # should_not be_within(delta).of(expected)
- #
# Passes if actual == expected +/- delta
#
- # == Example
+ # == Examples
#
# result.should be_within(0.5).of(3.0)
+ # result.should_not be_within(0.5).of(3.0)
def be_within(delta)
Matcher.new :be_within, delta do |_delta_|
chain :of do |_expected_|
View
@@ -1,10 +1,6 @@
module RSpec
module Matchers
- # :call-seq:
- # should eq(expected)
- # should_not eq(expected)
- #
- # Passes if actual == expected.
+ # Passes if <tt>actual == expected</tt>.
#
# See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
#
@@ -1,10 +1,6 @@
module RSpec
module Matchers
- # :call-seq:
- # should eql(expected)
- # should_not eql(expected)
- #
- # Passes if actual and expected are of equal value, but not necessarily the same object.
+ # Passes if +actual.eql?(expected)+
#
# See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
#
@@ -1,18 +1,13 @@
module RSpec
module Matchers
-
- # :call-seq:
- # should equal(expected)
- # should_not equal(expected)
- #
- # Passes if actual and expected are the same object (object identity).
+ # Passes if <tt>actual.equal?(expected)</tt> (object identity).
#
# See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
#
# == Examples
#
- # 5.should equal(5) #Fixnums are equal
- # "5".should_not equal("5") #Strings that look the same are not the same object
+ # 5.should equal(5) # Fixnums are equal
+ # "5".should_not equal("5") # Strings that look the same are not the same object
def equal(expected)
Matcher.new :equal, expected do |_expected_|
match do |actual|
@@ -1,7 +1,7 @@
module RSpec
module Matchers
class << self
- attr_accessor :last_matcher, :last_should # :nodoc:
+ attr_accessor :last_matcher, :last_should
end
def self.clear_generated_description
@@ -1,6 +1,6 @@
module RSpec
module Matchers
- class Have #:nodoc:
+ class Have
def initialize(expected, relativity=:exactly)
@expected = case expected
when :no then 0
@@ -41,11 +41,11 @@ def perform_match(predicate, hash_predicate, actual, _expected)
end
end
- def comparing_hash_keys?(actual, expected) # :nodoc:
+ def comparing_hash_keys?(actual, expected)
actual.is_a?(Hash) && !expected.is_a?(Hash)
end
- def comparing_hash_values?(actual, expected) # :nodoc:
+ def comparing_hash_values?(actual, expected)
actual.is_a?(Hash) && expected.is_a?(Hash)
end
end
@@ -1,7 +1,7 @@
module RSpec
module Matchers
- class MatchArray #:nodoc:
+ class MatchArray
include RSpec::Matchers::Pretty
def initialize(expected)
@@ -55,7 +55,7 @@ def include(*args)
singleton_class.__send__(:include, *args)
end
- def define_method(name, &block) # :nodoc:
+ def define_method(name, &block)
singleton_class.__send__(:define_method, name, &block)
end
@@ -119,7 +119,7 @@ def method_missing(method, *args, &block)
end
end
- def making_declared_methods_public # :nodoc:
+ def making_declared_methods_public
# Our home-grown instance_exec in ruby 1.8.6 results in any methods
# declared in the block eval'd by instance_exec in the block to which we
# are yielding here are scoped private. This is NOT the case for Ruby
@@ -3,7 +3,7 @@ module Matchers
private
- def method_missing(method, *args, &block) # :nodoc:
+ def method_missing(method, *args, &block)
return Matchers::BePredicate.new(method, *args, &block) if method.to_s =~ /^be_/
return Matchers::Has.new(method, *args, &block) if method.to_s =~ /^have_/
super
@@ -62,7 +62,7 @@ def eval_match(actual, operator, expected)
end
- class PositiveOperatorMatcher < OperatorMatcher #:nodoc:
+ class PositiveOperatorMatcher < OperatorMatcher
def __delegate_operator(actual, operator, expected)
if actual.__send__(operator, expected)
true
@@ -75,7 +75,7 @@ def __delegate_operator(actual, operator, expected)
end
- class NegativeOperatorMatcher < OperatorMatcher #:nodoc:
+ class NegativeOperatorMatcher < OperatorMatcher
def __delegate_operator(actual, operator, expected)
return false unless actual.__send__(operator, expected)
return fail_with_message("expected not: #{operator} #{expected.inspect}\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
@@ -1,6 +1,6 @@
module RSpec
module Matchers
- class RaiseError #:nodoc:
+ class RaiseError
def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
@block = block
@actual_error = nil
@@ -1,7 +1,7 @@
module RSpec
module Matchers
- class RespondTo #:nodoc:
+ class RespondTo
def initialize(*names)
@names = names
@expected_arity = nil
@@ -1,7 +1,7 @@
module RSpec
module Matchers
- class Satisfy #:nodoc:
+ class Satisfy
def initialize(&block)
@block = block
end
@@ -1,7 +1,7 @@
module RSpec
module Matchers
- class ThrowSymbol #:nodoc:
+ class ThrowSymbol
def initialize(expected_symbol = nil, expected_arg=nil)
@expected_symbol = expected_symbol
@expected_arg = expected_arg

0 comments on commit 4638609

Please sign in to comment.