Class: IncludeWith
- Inherits:
-
Object
- Object
- IncludeWith
- Defined in:
- lib/itesttool/custom_matchers.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
-
#initialize(key, values) ⇒ IncludeWith
constructor
A new instance of IncludeWith.
- #matches?(rows) ⇒ Boolean
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_should ⇒ Object
157 158 159 160 |
# File 'lib/itesttool/custom_matchers.rb', line 157 def str = @values.map{|x| "#{@key} => #{x}"}.join(" and ") "expected #{@rows.inspect} to include #{str}" end |
#matches?(rows) ⇒ 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 |