Skip to content

Instantly share code, notes, and snippets.

@dinks
Created May 26, 2015 14:26
Show Gist options
  • Save dinks/66dab4b89d5f2d6269ab to your computer and use it in GitHub Desktop.
Save dinks/66dab4b89d5f2d6269ab to your computer and use it in GitHub Desktop.
Test Middleware in Rails
require 'spec_helper'
describe MyMiddleWare do
let(:app) { ->(env) { [200, env, ""] } }
let :middleware do
MyMiddleWare.new(app)
end
let(:params) do
{
input: data
}
end
let(:data) { '' }
subject do
middleware.call Rack::MockRequest.env_for('http://www.test.dev/', params.merge(method: 'POST'))
end
it 'does not raise and exception' do
expect { subject }.not_to raise_error
end
it 'does not set the request_parameters' do
status, env = subject
expect(env['action_dispatch.request.request_parameters']).to eq(nil)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment