Module: JsonHelpers

Defined in:
lib/utensils/json.rb

Instance Method Summary collapse

Instance Method Details

#expect_json(json, path = nil) ⇒ Object



6
7
8
# File 'lib/utensils/json.rb', line 6

def expect_json(json, path = nil)
  expect(parse_json(json, path))
end

#expect_json_response(path = nil) ⇒ Object



2
3
4
# File 'lib/utensils/json.rb', line 2

def expect_json_response(path = nil)
  expect(json_response(path))
end

#json_response(path = nil) ⇒ Object



10
11
12
# File 'lib/utensils/json.rb', line 10

def json_response(path = nil)
  parse_json(spec_type_agnostic_response_body, path)
end

#save_and_open_jsonObject

Similar to ‘save_and_open_page`, to temporarily inspect nicely formatted contents of JSON response



15
16
17
18
19
20
21
# File 'lib/utensils/json.rb', line 15

def save_and_open_json
  file_path = Rails.root.join("tmp", "json.rb").to_s
  output = parse_json(spec_type_agnostic_response_body)
  output = PP.pp(output, "")
  File.write(file_path, output, mode: "wb")
  Launchy.open(file_path)
end