Class: Polyrun::Quick::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrun/quick/matchers.rb

Overview

Minimal expect(x).to … chain (RSpec-ish) without RSpec.

Instance Method Summary collapse

Constructor Details

#initialize(actual) ⇒ Expectation

Returns a new instance of Expectation.



7
8
9
# File 'lib/polyrun/quick/matchers.rb', line 7

def initialize(actual)
  @actual = actual
end

Instance Method Details

#not_to(matcher) ⇒ Object

Raises:



17
18
19
20
21
# File 'lib/polyrun/quick/matchers.rb', line 17

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

  raise AssertionFailed, matcher.failure_message_when_negated(@actual)
end

#to(matcher) ⇒ Object

Raises:



11
12
13
14
15
# File 'lib/polyrun/quick/matchers.rb', line 11

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

  raise AssertionFailed, matcher.failure_message(@actual)
end