Class: Barometer::Support::Matchers::HaveData
- Inherits:
-
Object
- Object
- Barometer::Support::Matchers::HaveData
show all
- Includes:
- Formats
- Defined in:
- lib/barometer/support/matchers/have_data.rb
Instance Method Summary
collapse
Methods included from Formats
#_find_regex, #is_of_format?
Constructor Details
#initialize(*paths) ⇒ HaveData
Returns a new instance of HaveData.
14
15
16
|
# File 'lib/barometer/support/matchers/have_data.rb', line 14
def initialize(*paths)
@paths = paths
end
|
Instance Method Details
41
42
43
44
|
# File 'lib/barometer/support/matchers/have_data.rb', line 41
def as_format(format)
@format = format
self
end
|
#as_value(value) ⇒ Object
36
37
38
39
|
# File 'lib/barometer/support/matchers/have_data.rb', line 36
def as_value(value)
@value = value
self
end
|
#description ⇒ Object
32
33
34
|
# File 'lib/barometer/support/matchers/have_data.rb', line 32
def description
"have correct value for #{@paths.join('.')}"
end
|
#failure_message ⇒ Object
28
29
30
|
# File 'lib/barometer/support/matchers/have_data.rb', line 28
def failure_message
"expected that '#{@result}' matches '#{@value || @format}'"
end
|
#matches?(subject) ⇒ Boolean
18
19
20
21
22
23
24
25
26
|
# File 'lib/barometer/support/matchers/have_data.rb', line 18
def matches?(subject)
@result = Walker.new(subject).follow(@paths)
if @format
is_of_format?(@format, @result)
else
@result == @value || @result.to_f == @value
end
end
|