Module: WorkableJsonAssertions::Assertions

Defined in:
lib/workable_json_assertions/assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_json_response_emptyObject



6
7
8
# File 'lib/workable_json_assertions/assertions.rb', line 6

def assert_json_response_empty
  assert_empty response.body.strip
end

#assert_json_response_equal(json) ⇒ Object



10
11
12
13
# File 'lib/workable_json_assertions/assertions.rb', line 10

def assert_json_response_equal(json)
  json = json.with_indifferent_access if json.is_a?(Hash)
  assert_equal json, JSON.parse(response.body.strip)
end

#assert_json_response_equal_except(json, blacklist = []) ⇒ Object



15
16
17
18
# File 'lib/workable_json_assertions/assertions.rb', line 15

def assert_json_response_equal_except(json, blacklist = [])
  json = json.with_indifferent_access if json.is_a?(Hash)
  assert_json_equal_except(json, JSON.parse(response.body), blacklist)
end

#assert_json_response_includes(hash) ⇒ Object



20
21
22
# File 'lib/workable_json_assertions/assertions.rb', line 20

def assert_json_response_includes(hash)
  assert_match hash.to_json, response.body
end