Sha256: 6bc2f7653c1e0115f96d8f994a0fd48202faed63d5a99ebb6081d4cb03303437
Contents?: true
Size: 1.52 KB
Versions: 5
Compression:
Stored size: 1.52 KB
Contents
ENV['RACK_ENV'] = 'test' require 'rack/test' require 'minitest/autorun' require 'minitest/pride' require 'pry' require 'pry-nav' $:.push File.expand_path '../../lib', __FILE__ require 'jsonatra' include Rack::Test::Methods def app @controller end def mock_app &block @controller = Sinatra.new Jsonatra::Base, &block end def r JSON.parse last_response.body end def get_and_post *args, &block get *args yield setup post *args yield end JSON_CT = { 'CONTENT_TYPE' => 'application/json' } def post_json path, params = {}, headers = {} post path, params.to_json, headers.merge(JSON_CT) end def get_and_post_and_post_json path, params = {}, headers = {}, &block get_and_post path, params, headers, &block post_json path, params, headers, &block end alias gapapj get_and_post_and_post_json def must_have_parameter_error_for parameter, type = :invalid, error_type = :invalid_input last_response.status.must_equal 200 r['error'].wont_be_nil r['error']['type'].must_equal error_type.to_s r['error']['parameters'].wont_be_nil r['error']['parameters'][parameter.to_s].wont_be_empty r['error']['parameters'][parameter.to_s].first['type'].must_equal type.to_s end def must_have_header_error_for header, type = :invalid, error_type = :invalid_header last_response.status.must_equal 200 r['error'].wont_be_nil r['error']['type'].must_equal error_type.to_s r['error']['headers'].wont_be_nil r['error']['headers'][header.to_s].wont_be_empty r['error']['headers'][header.to_s].first['type'].must_equal type.to_s end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
jsonatra-1.0.7 | test/helper.rb |
jsonatra-1.0.5 | test/helper.rb |
jsonatra-1.0.4 | test/helper.rb |
jsonatra-1.0.3 | test/helper.rb |
jsonatra-1.0.2 | test/helper.rb |