Created
July 19, 2016 18:57
-
-
Save daveshah/6532311614be470900c6d2ff0f98db89 to your computer and use it in GitHub Desktop.
Testing middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
describe Rack::MyMiddleware do | |
let(:app) { proc { [200, {}, ['Hello Dave']] } } | |
let(:stack) { described_class.new(app) } | |
let(:request) { Rack::MockRequest.new(stack) } | |
context 'A POST request' do | |
#NOTE TIL = this is how I post all the things | |
let(:response) { request.post('/' , opts={ | |
:input => "{ 'foo' : 'bar'}}", #NOTE: :input is the raw input | |
'action_dispatch.request.request_parameters' => { 'foooo' => 'baaaar'} | |
#NOTE: the above is input that's ready after http://api.rubyonrails.org/classes/ActionDispatch/Http/Parameters.html has had it's way with it. | |
#checkout https://github.com/rack/rack/blob/master/lib/rack/mock.rb | |
#any strings added to opts get added to 'env' | |
})} | |
it 'does all the things!' do | |
#TODO: All the things! | |
expect(response.headers).to_not be nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment