Sha256: 5c21f2d103259eb13ffad22e4c10ce9ba1610b4c9b237a14bafe63197d8b5924
Contents?: true
Size: 678 Bytes
Versions: 23
Compression:
Stored size: 678 Bytes
Contents
class Hash def sort_by_key(&block) self.keys.sort(&block).reduce({}) do |seed, key| seed[key] = self[key] if seed[key].is_a?(Hash) seed[key] = seed[key].sort_by_key(&block) elsif seed[key].is_a?(Array) seed[key] = seed[key].map do |i| i.respond_to?(:sort_by_key) ? i.sort_by_key(&block) : i end end seed end end end Then /^the output should contain JSON:$/ do |data| parsed = ERB.new(data).result target = JSON.pretty_generate(JSON.parse(parsed).sort_by_key) actual = JSON.pretty_generate(JSON.parse(all_commands.map { |c| c.output }.join("\n")).sort_by_key) expect(actual).to eq(target) end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
berkshelf-4.2.0 | features/step_definitions/json_steps.rb |
berkshelf-4.1.1 | features/step_definitions/json_steps.rb |
berkshelf-4.1.0 | features/step_definitions/json_steps.rb |