Class: Shaf::Spec::IntegrationSpec

Inherits:
Minitest::Spec
  • Object
show all
Includes:
Minitest::Hooks, HttpMethodUtils, PayloadUtils, UriHelper
Defined in:
lib/shaf/spec/integration_spec.rb

Constant Summary collapse

TRANSACTION_OPTIONS =
{
  rollback: :always,
  savepoint: true,
  auto_savepoint: true
}.freeze

Instance Method Summary collapse

Methods included from UriHelperMethods

eval_method, register

Methods included from PayloadUtils

#assert_attribute, #assert_has_attribute, #assert_has_attributes, #assert_has_embedded, #assert_has_link, #assert_has_links, #assert_header, #assert_link, #assert_status, #attributes, #embedded, #embedded_each, #embedded_resources, #fill_form, #last_payload, #link_rels, #links, #refute_has_attribute, #refute_has_attributes, #refute_has_embedded, #refute_has_link, #refute_has_links, #set_payload

Methods included from HttpMethodUtils

#headers, #status

Instance Method Details

#appObject



35
36
37
# File 'lib/shaf/spec/integration_spec.rb', line 35

def app
  App.instance
end

#follow_rel(rel, method: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/shaf/spec/integration_spec.rb', line 39

def follow_rel(rel, method: nil)
  assert_has_link(rel)
  link = links[rel.to_sym]
  if method && respond_to?(method)
    public_send(method, link[:href])
  else
    get link[:href]
  end
end

#parse_response(body) ⇒ Object



30
31
32
33
# File 'lib/shaf/spec/integration_spec.rb', line 30

def parse_response(body)
  return nil if body.empty?
  JSON.parse(body, symbolize_names: true)
end

#set_headersObject



24
25
26
27
28
# File 'lib/shaf/spec/integration_spec.rb', line 24

def set_headers
  if defined?(@__integration_test_auth_token) && @__integration_test_auth_token
    header 'X-AUTH-TOKEN', @__integration_test_auth_token
  end
end