-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1005 from urkle/fix-globals-middleware
fix the Globals middleware
- Loading branch information
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe Grape::Middleware::Globals do | ||
subject { Grape::Middleware::Globals.new(blank_app) } | ||
before { allow(subject).to receive(:dup).and_return(subject) } | ||
|
||
let(:blank_app) { lambda { |env| [200, {}, 'Hi there.'] } } | ||
|
||
it 'calls through to the app' do | ||
expect(subject.call({})).to eq([200, {}, 'Hi there.']) | ||
end | ||
|
||
context 'environment' do | ||
it 'should set the grape.request environment' do | ||
subject.call({}) | ||
expect(subject.env['grape.request']).to be_a(Grape::Request) | ||
end | ||
it 'should set the grape.request.headers environment' do | ||
subject.call({}) | ||
expect(subject.env['grape.request.headers']).to be_a(Hash) | ||
end | ||
it 'should set the grape.request.params environment' do | ||
subject.call('QUERY_STRING' => 'test=1', 'rack.input' => StringIO.new) | ||
expect(subject.env['grape.request.params']).to be_a(Hash) | ||
end | ||
end | ||
end |