Class: LookLike::Matcher

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

Direct Known Subclasses

ArrayMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Matcher

Returns a new instance of Matcher.



9
10
11
12
13
14
# File 'lib/look_like/matcher.rb', line 9

def initialize(config)
  @name     = config[:name]
  @desc     = config[:desc]
  @selector = config[:select]
  @matcher  = config[:match]
end

Instance Attribute Details

#descObject

Returns the value of attribute desc.



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

def desc
  @desc
end

#error(actual, expected) ⇒ Object

Returns the value of attribute error.



7
8
9
# File 'lib/look_like/matcher.rb', line 7

def error
  @error
end

#match(actual, expected) ⇒ Object

Returns the value of attribute match.



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

def match
  @match
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/look_like/matcher.rb', line 3

def name
  @name
end

#select(expected) ⇒ Object

Returns the value of attribute select.



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

def select
  @select
end

Instance Method Details

#negate_error(actual, expected) ⇒ Object



20
21
22
# File 'lib/look_like/matcher.rb', line 20

def negate_error(actual, expected)
  "Did not expect    :\"#{actual}\" to look like  : \"#{expected}\" (#{@desc})"
end