Sha256: 2d4fd51fbb52df1c2da7ff5a5e4502661e733fb96729c57e00f1a58115e324dc
Contents?: true
Size: 1.5 KB
Versions: 6
Compression:
Stored size: 1.5 KB
Contents
module JSONRequests def json_get(url, arg2 = nil) get rootify(url), arg2, { 'HTTP_ACCEPT' => 'application/json' } end def json_post(url, arg2 = nil) post rootify(url), arg2, { 'HTTP_ACCEPT' => 'application/json' } end def json_put(url, arg2 = nil) put rootify(url), arg2, { 'HTTP_ACCEPT' => 'application/json' } end def json_delete(url, arg2 = nil) delete rootify(url), arg2, { 'HTTP_ACCEPT' => 'application/json' } end def authenticated_json_get(user, url, arg2 = nil) auth_header = user.create_new_auth_token get rootify(url), arg2, auth_header.merge({ 'HTTP_ACCEPT' => 'application/json' }) end def authenticated_json_post(user, url, arg2 = nil) auth_header = user.create_new_auth_token post rootify(url), arg2, auth_header.merge({ 'HTTP_ACCEPT' => 'application/json' }) end def authenticated_json_put(user, url, arg2 = nil) auth_header = user.create_new_auth_token put rootify(url), arg2, auth_header.merge({ 'HTTP_ACCEPT' => 'application/json' }) end def authenticated_json_delete(user, url, arg2 = nil) auth_header = user.create_new_auth_token delete rootify(url), arg2, auth_header.merge({ 'HTTP_ACCEPT' => 'application/json' }) end def rootify(url) if url[0] == '/' url else "/#{url}" end end end module RSpec::Rails::RequestExampleGroup include JSONRequests include JsonSpec::Matchers include JsonSpec::Helpers end RSpec.configure do |config| config.include JsonSpec::Helpers, :type => :serializer end
Version data entries
6 entries across 6 versions & 1 rubygems