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.
45 46 47 |
# File 'lib/crspec/expectations.rb', line 45 def initialize(actual) @actual = actual end |
Instance Method Details
#not_to(matcher = nil, &block) ⇒ Object Also known as: to_not
61 62 63 64 65 66 67 68 69 |
# File 'lib/crspec/expectations.rb', line 61 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" fail_with(msg) return false end true end |
#to(matcher = nil, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/crspec/expectations.rb', line 49 def to(matcher = nil, &block) matcher ||= block return matcher.setup_expect(@actual) if matcher.respond_to?(:setup_expect) unless matcher.matches?(@actual) fail_with(matcher.) return false end true end |