Sha256: 7ab1ac780ace152fe61753a0f9ebe579b5916b24facb8fb7b6325a58a93d1ef4

Contents?: true

Size: 885 Bytes

Versions: 9

Compression:

Stored size: 885 Bytes

Contents

ENV['RACK_ENV'] = 'test'

begin
  require 'rack'
rescue LoadError
  require 'rubygems'
  require 'rack'
end

testdir = File.dirname(__FILE__)
$LOAD_PATH.unshift(testdir) unless $LOAD_PATH.include?(testdir)

libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

require 'test/unit'
require 'rack/accept'

class Test::Unit::TestCase
  attr_reader :context
  attr_reader :response

  def status
    @response && @response.status
  end

  def request(env={}, method='GET', uri='/')
    @context = Rack::Accept.new(fake_app)
    yield @context if block_given?
    mock_request = Rack::MockRequest.new(@context)
    @response = mock_request.request(method.to_s.upcase, uri, env)
    @response
  end

  def fake_app(status=200, headers={}, body=[])
    lambda {|env| Rack::Response.new(body, status, headers).finish }
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rack-accept-0.4.5/test/helper.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rack-accept-0.4.5/test/helper.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rack-accept-0.4.5/test/helper.rb
rack-accept-0.4.5 test/helper.rb
rack-accept-0.4.4 test/helper.rb
rack-accept-0.4.3 test/helper.rb
rack-accept-0.4.2 test/helper.rb
rack-accept-0.4.1 test/helper.rb
rack-accept-0.3 test/helper.rb