Class: Lanes::ApiTestCase

Inherits:
TestCase
  • Object
show all
Includes:
Rack::Test::Methods
Defined in:
lib/lanes/spec_helper.rb

Constant Summary

Constants included from Lanes

VERSION

Instance Method Summary collapse

Methods inherited from TestCase

#admin

Methods included from Lanes

config, configure, env, logger, logger=, logger_debug, silence_logs

Instance Method Details

#appObject



62
63
64
# File 'lib/lanes/spec_helper.rb', line 62

def app
    Lanes::API::Root.new
end

#assert_okObject



88
89
90
# File 'lib/lanes/spec_helper.rb', line 88

def assert_ok
    assert last_response.ok?, "Request failed with #{last_response.status}"
end

#json_bodyObject



66
67
68
# File 'lib/lanes/spec_helper.rb', line 66

def json_body
    Hashie::Mash.new Oj.load( last_response.body )
end

#json_dataObject



70
71
72
# File 'lib/lanes/spec_helper.rb', line 70

def json_data
    json_body['data']
end

#login!(user = admin) ⇒ Object



84
85
86
# File 'lib/lanes/spec_helper.rb', line 84

def login!(user=admin)
    @current_user = user
end

#refute_okObject



91
92
93
# File 'lib/lanes/spec_helper.rb', line 91

def refute_ok
    refute last_response.ok?, "Request succeeded with status #{last_response.status}, expected non-2XX"
end