Class: Easytest::Matcher::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/easytest/matcher/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actual:, expected:, negate: false) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/easytest/matcher/base.rb', line 9

def initialize(actual:, expected:, negate: false)
  @actual = actual
  @expected = expected
  @negate = negate
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



4
5
6
# File 'lib/easytest/matcher/base.rb', line 4

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



5
6
7
# File 'lib/easytest/matcher/base.rb', line 5

def expected
  @expected
end

#negateObject (readonly) Also known as: negate?

Returns the value of attribute negate.



6
7
8
# File 'lib/easytest/matcher/base.rb', line 6

def negate
  @negate
end

Instance Method Details

#match!Object



19
20
21
22
23
# File 'lib/easytest/matcher/base.rb', line 19

def match!
  matched = match?
  matched = !matched if negate?
  raise_match_error unless matched
end

#match?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/easytest/matcher/base.rb', line 15

def match?
  raise NotImplementedError
end