Class: IncludeWith

Inherits:
Object
  • Object
show all
Defined in:
lib/itesttool/custom_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, values) ⇒ IncludeWith

Returns a new instance of IncludeWith.



147
148
149
150
# File 'lib/itesttool/custom_matchers.rb', line 147

def initialize(key, values)
  @key = key
  @values = values
end

Instance Method Details

#failure_message_for_shouldObject



157
158
159
160
# File 'lib/itesttool/custom_matchers.rb', line 157

def failure_message_for_should
  str = @values.map{|x| "#{@key} => #{x}"}.join(" and ")
  "expected #{@rows.inspect} to include #{str}"
end

#matches?(rows) ⇒ Boolean

Returns:

  • (Boolean)


151
152
153
154
155
# File 'lib/itesttool/custom_matchers.rb', line 151

def matches?(rows)
  @rows = rows
  list = rows.map{|x| x[@key]}
  Set[*list] == Set[*@values]
end