Friday, December 12, 2014

change Rack Test default host

If you're using Rack Test to test requests on your Sinatra application you will notice that by default the host isexample.org.
you can change this like this:
# spec/spec_helper.rb
def app
  MySinatraOrRackApp
end

module Rack
  module Test
    module Methods
      def build_rack_mock_session
        Rack::MockSession.new(app, 'api.myapp.com')
      end
    end
  end
end

# this has to be done before you do  `include Rack::Test::Methods`
note: Rack Test is the lib that is repsonsible for request test, so when you do post('/events')get('/', token: 123), ...

source: