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

Version Path
looksist-0.3.12 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.11 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.10 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.9 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.8 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.7 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.6 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.5 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.4 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.3 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.2 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.1 features/step_definitions/hash_lookup_steps.rb
looksist-0.3.0 features/step_definitions/hash_lookup_steps.rb
looksist-0.2.10 features/step_definitions/hash_lookup_steps.rb
looksist-0.2.9 features/step_definitions/hash_lookup_steps.rb