Skip to content

Commit

Permalink
put the rdoc for should, should_not, and expect where yard can pick i…
Browse files Browse the repository at this point in the history
…t up
  • Loading branch information
dchelimsky committed Jun 14, 2012
1 parent 43526ec commit 7847016
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions lib/rspec/expectations/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,41 @@ module Expectations
module Syntax
extend self

# @method should
# Passes if `matcher` returns true. Available on every `Object`.
# @example
# actual.should eq expected
# actual.should match /expression/
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] true if the expectation succeeds (else raises)
# @see RSpec::Matchers

# @method should_not
# Passes if `matcher` returns false. Available on every `Object`.
# @example
# actual.should_not eq expected
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] false if the negative expectation succeeds (else raises)
# @see RSpec::Matchers

# @method expect
# Wraps `target` in an `ExpectationTarget`
# @return [ExpectationTarget]

# @api private
# Enables the `should` syntax.
def enable_should(syntax_host = ::Kernel)
return if should_enabled?(syntax_host)

syntax_host.module_eval do
# Passes if +matcher+ returns true. Available on every +Object+.
# @example
# actual.should eq(expected)
# actual.should be > 4
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] true if the expectation succeeds (else raises)
# @see RSpec::Matchers
def should(matcher=nil, message=nil, &block)
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
end

# Passes if +matcher+ returns false. Available on every +Object+.
# @example
# actual.should_not eq(expected)
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] false if the negative expectation succeeds (else raises)
# @see RSpec::Matchers
def should_not(matcher=nil, message=nil, &block)
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
end
Expand Down Expand Up @@ -88,4 +96,3 @@ def expect_enabled?(syntax_host = ::RSpec::Matchers)
end
end
end

0 comments on commit 7847016

Please sign in to comment.