Module: RSpec::Expectations::ExpectationTarget::InstanceMethods
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | rspec-expectations/lib/rspec/expectations/expectation_target.rb |
Overview
Defines instance ::RSpec::Expectations::ExpectationTarget
instance methods. These are defined in a module so we can include it in Minitest::Expectation
when rspec/expectations/minitest_integration
is loaded in order to support usage with Minitest.
Instance Method Summary
-
#not_to(matcher = nil, message = nil, &block) ⇒ Boolean
(also: #to_not)
Runs the given expectation, passing if
matcher
returns false. -
#to(matcher = nil, message = nil, &block) ⇒ Boolean
Runs the given expectation, passing if
matcher
returns true. -
#to_not(matcher = nil, message = nil, &block)
Alias for #not_to.
- #prevent_operator_matchers(verb) private
Instance Method Details
#not_to(matcher = nil, message = nil, &block) ⇒ Boolean
Also known as: #to_not
Runs the given expectation, passing if matcher
returns false.
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 76
def not_to(matcher=nil, =nil, &block) prevent_operator_matchers(:not_to) unless matcher RSpec::Expectations::NegativeExpectationHandler.handle_matcher(target, matcher, , &block) end
#prevent_operator_matchers(verb) (private)
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 84
def prevent_operator_matchers(verb) raise ArgumentError, "The expect syntax does not support operator matchers, " \ "so you must pass a matcher to `##{verb}`." end
#to(matcher = nil, message = nil, &block) ⇒ Boolean
Runs the given expectation, passing if matcher
returns true.
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 63
def to(matcher=nil, =nil, &block) prevent_operator_matchers(:to) unless matcher RSpec::Expectations::PositiveExpectationHandler.handle_matcher(target, matcher, , &block) end
#to_not(matcher = nil, message = nil, &block)
Alias for #not_to.
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 80
alias to_not not_to