Class: HaveTable::RowMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/have_table/row_matcher.rb

Instance Method Summary collapse

Instance Method Details

#matches?(row_sequence) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/have_table/row_matcher.rb', line 8

def matches?(row_sequence)
  # Tester called: have_table { with_row }
  return row_sequence.any? unless @row_conditions

  matches = false
  row_sequence.each do |row|
    row_matches = true
    @row_conditions.each do |key, value|
      unless row[key] == value
        row_matches = false
        break
      end
    end

    if row_matches
      matches = true
      break
    end
  end
  return matches
end

#with_cell(params) ⇒ Object



3
4
5
6
# File 'lib/have_table/row_matcher.rb', line 3

def with_cell(params)
  @row_conditions ||= {}
  @row_conditions.merge!(params)
end