Sha256: 09be5e9c980167179afc4ef464c26e3e147c7045cfb1e8d8ef33ede94ec75032
Contents?: true
Size: 1.21 KB
Versions: 15
Compression:
Stored size: 1.21 KB
Contents
When(/^I ask (DeepHash|Menu|ArrayOfHash) for (metrics|menu)$/) do |lookup_service, method| @enriched_hash = Object.const_get(lookup_service.classify).new.send(method) end Then(/^I should see the following "([^"]*)" be injected into the hash at "([^"]*)"$/) do |target, json_path, table| expected_names = table.hashes.collect { |row| row[:value] } actual_names = JsonPath.new("#{json_path}.#{target.parameterize.underscore.singularize}").on(@enriched_hash.with_indifferent_access) expect(actual_names.size).to eq(1) expect(actual_names.first).to eq(expected_names) end Then(/^I should see the following "([^"]*)" enriched for each sub hash at "([^"]*)"$/) do |name, jsonpath, table| expect(JsonPath.new(jsonpath).on(@enriched_hash.with_indifferent_access).first.collect { |i| i[name.parameterize.underscore.to_sym] }).to eq(table.hashes.collect { |i| i[:value] }) end Then(/^I should see the following "([^"]*)" in all the hashes$/) do |name, table| expected_names = table.hashes.collect { |row| row[:value] } method_name = "#{name.parameterize.underscore.singularize}" actual_names = @enriched_hash.collect do |elt| elt.with_indifferent_access["#{method_name}"] end expect(actual_names).to eq(expected_names) end
Version data entries
15 entries across 15 versions & 1 rubygems