class Shaf::Spec::IntegrationSpec
Attributes
__authenticated_user_id[RW]
Private Instance Methods
app()
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 32 def app App.app end
authenticate(user)
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 36 def authenticate(user) self.__authenticated_user_id = user&.id end
follow_rel(rel, method: nil)
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 51 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)
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 25 def parse_response(body) return nil if body.empty? JSON.parse(body, symbolize_names: true) rescue JSON::ParserError => e assert e.nil?, "Could not parse reponse as json (#{body[0..40]})" end
set_authentication()
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 18 def set_authentication id = __authenticated_user_id authorization = "#{Authenticator.scheme} #{id}" if id header 'Authorization', authorization end
unauthenticate()
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 40 def unauthenticate self.__authenticated_user_id = nil end
with_authenticated(user) { || ... }
click to toggle source
# File lib/shaf/spec/integration_spec.rb, line 44 def with_authenticated(user, &block) authenticate(user) yield ensure unauthenticate end