Class: Smartest::ExpectationTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/smartest/expectation_target.rb

Instance Method Summary collapse

Constructor Details

#initialize(actual) ⇒ ExpectationTarget

Returns a new instance of ExpectationTarget.



5
6
7
# File 'lib/smartest/expectation_target.rb', line 5

def initialize(actual)
  @actual = actual
end

Instance Method Details

#not_to(matcher) ⇒ Object

Raises:



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/smartest/expectation_target.rb', line 15

def not_to(matcher)
  if matcher.respond_to?(:does_not_match?)
    return self if matcher.does_not_match?(@actual)

    raise AssertionFailed, matcher.negated_failure_message
  end

  return self unless matcher.matches?(@actual)

  raise AssertionFailed, matcher.negated_failure_message
end

#to(matcher) ⇒ Object

Raises:



9
10
11
12
13
# File 'lib/smartest/expectation_target.rb', line 9

def to(matcher)
  return self if matcher.matches?(@actual)

  raise AssertionFailed, matcher.failure_message
end