Module: Helpers::JsonHelper

Defined in:
lib/generators/disco_app/install/templates/spec/support/helpers/json_helper.rb

Instance Method Summary collapse

Instance Method Details

#json_fixture(path, dir: 'json', parse: true) ⇒ Object

Return a JSON fixture as an indifferent hash.



5
6
7
8
9
10
# File 'lib/generators/disco_app/install/templates/spec/support/helpers/json_helper.rb', line 5

def json_fixture(path, dir: 'json', parse: true)
  filename = Rails.root.join('spec', 'fixtures', 'files', dir, "#{path}.json")
  return File.read(filename) unless parse

  HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(File.read(filename)))
end