Sha256: 0dd439d33867c6bff592d6cce7021b17511c38338854c52a1630d68bd3ffa29e

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

module ElabsMatchers
  module Helpers
    module Common

      ##
      #
      # Normalizes a hash so that it can be described in a more
      # human friendly manner.
      #
      # Examples:
      # { "First name" => "Adam" } => HashWithIndifferentAccess.new({ "first_name" => "adam" })
      #
      # # 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("_")] = value
          new_hash
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elabs_matchers-0.0.2 lib/elabs_matchers/helpers/common.rb
elabs_matchers-0.0.1 lib/elabs_matchers/helpers/common.rb