Module: Archipelago::TestHelpers

Defined in:
lib/archipelago/test_helpers.rb

Instance Method Summary collapse

Instance Method Details

#assert_island_errors(field) ⇒ Object



25
26
27
28
29
# File 'lib/archipelago/test_helpers.rb', line 25

def assert_island_errors(field)
  body = parsed_island_response
  assert_equal "error", body["status"]
  assert body.fetch("errors").key?(field.to_s)
end

#assert_island_props(key, value) ⇒ Object



13
14
15
16
17
# File 'lib/archipelago/test_helpers.rb', line 13

def assert_island_props(key, value)
  body = parsed_island_response
  assert_equal "ok", body["status"]
  assert_equal value, body.fetch("props").fetch(key.to_s)
end

#assert_island_redirect(path) ⇒ Object



19
20
21
22
23
# File 'lib/archipelago/test_helpers.rb', line 19

def assert_island_redirect(path)
  body = parsed_island_response
  assert_equal "redirect", body["status"]
  assert_equal path, body["location"]
end

#island_post(component, operation, params = {}) ⇒ Object



5
6
7
# File 'lib/archipelago/test_helpers.rb', line 5

def island_post(component, operation, params = {})
  post "/islands/#{component}/#{operation}", params: params, as: :json
end

#parsed_island_responseObject



9
10
11
# File 'lib/archipelago/test_helpers.rb', line 9

def parsed_island_response
  JSON.parse(response.body)
end