testing/cucumber/step_definitions/verification_steps.rb in cql-1.3.0 vs testing/cucumber/step_definitions/verification_steps.rb in cql-1.4.0
- old
+ new
@@ -1,17 +1,19 @@
Then(/^the following values are returned:$/) do |values|
+ expected_keys = values.raw.first
expected_results = values.hashes
- expected_results.each { |result| result['source_line'] = result['source_line'].to_i if result['source_line'] }
- expected_results.each { |result| result['scenario_line'] = result['scenario_line'].to_i if result['scenario_line'] }
- expected_results.each { |result| result['tags'] = eval(result['tags']) if result['tags'] }
- expected_results.each { |result| result['scenario_tags'] = eval(result['scenario_tags']) if result['scenario_tags'] }
expected_results.each do |result|
- result.each_pair { |key, value| result[key] = value.sub('path/to', @default_file_directory) if value =~ /path\/to/ }
+ result.each_pair { |key, value| result[key] = value.to_i if value =~ /^\d+$/ }
end
- expect(@query_results).to match_array(expected_results)
+
+ @query_results.each_with_index do |result, index|
+ # Key order doesn't matter and Ruby 1.8.7 does not retain hash key ordering, so sorting them for consistency
+ expect(result.keys.sort).to eq(expected_keys.sort)
+ expect(result).to eq(expected_results[index])
+ end
end
# Then(/^all of them can be queried for additional information$/) do
#
# expect(@cm_models).to_not be_empty
@@ -43,11 +45,13 @@
expect { eval(code_text) }.to_not raise_error
end
Then(/^all of them can be queried$/) do |code_text|
+ original_text = code_text
+
@available_model_classes.each do |clazz|
- code_text.gsub!('<model_class>', clazz.to_s)
+ code_text = original_text.gsub('<model_class>', clazz.to_s)
expect(clazz.new).to respond_to(:query)
# Make sure that the example code is valid
expect { eval(code_text) }.to_not raise_error