Sha256: e5f5ba57ebd2d51339ed327f92967d44078330b366d11a8f3b54d08400a913ed
Contents?: true
Size: 680 Bytes
Versions: 2
Compression:
Stored size: 680 Bytes
Contents
module ElabsMatchers module Helpers module NormalizeKeys rspec ## # # Normalizes a hash so that it can be described in a more # human friendly manner. # # @param [Hash] hash A hash of human-friendly key and value pairs. # # Examples: # # # Or in a Cucumber table: # Given the following people: # | First name | Last name | # | Douglas | Adams | def normalize_keys(hash) hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)| new_hash[key.parameterize(separator: "_")] = value new_hash end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elabs_matchers-2.0.1 | lib/elabs_matchers/helpers/normalize_keys.rb |
elabs_matchers-2.0.0 | lib/elabs_matchers/helpers/normalize_keys.rb |