module Helpers::JsonHelper

Public Instance Methods

json_fixture(path, dir: 'json', parse: true) click to toggle source

Return a JSON fixture as an indifferent hash.

# 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