Class: Crspec::ExpectationTarget
- Inherits:
-
Object
- Object
- Crspec::ExpectationTarget
- Defined in:
- lib/crspec/expectations.rb
Instance Method Summary collapse
-
#initialize(actual) ⇒ ExpectationTarget
constructor
A new instance of ExpectationTarget.
- #not_to(matcher = nil, &block) ⇒ Object (also: #to_not)
- #to(matcher = nil, &block) ⇒ Object
Constructor Details
#initialize(actual) ⇒ ExpectationTarget
Returns a new instance of ExpectationTarget.
9 10 11 |
# File 'lib/crspec/expectations.rb', line 9 def initialize(actual) @actual = actual end |
Instance Method Details
#not_to(matcher = nil, &block) ⇒ Object Also known as: to_not
22 23 24 25 26 27 28 29 |
# File 'lib/crspec/expectations.rb', line 22 def not_to(matcher = nil, &block) matcher ||= block if matcher.matches?(@actual) msg = matcher.respond_to?(:failure_message_when_negated) ? matcher. : "Expected matcher not to match" raise ExpectationNotMetError, msg end true end |
#to(matcher = nil, &block) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/crspec/expectations.rb', line 13 def to(matcher = nil, &block) matcher ||= block return matcher.setup_expect(@actual) if matcher.respond_to?(:setup_expect) raise ExpectationNotMetError, matcher. unless matcher.matches?(@actual) true end |