-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathglobals_spec.rb
30 lines (23 loc) · 918 Bytes
/
globals_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true
describe Grape::Middleware::Globals do
subject { described_class.new(blank_app) }
before { allow(subject).to receive(:dup).and_return(subject) }
let(:blank_app) { ->(_env) { [200, {}, 'Hi there.'] } }
it 'calls through to the app' do
expect(subject.call({})).to eq([200, {}, 'Hi there.'])
end
context 'environment' do
it 'sets the grape.request environment' do
subject.call({})
expect(subject.env[Grape::Env::GRAPE_REQUEST]).to be_a(Grape::Request)
end
it 'sets the grape.request.headers environment' do
subject.call({})
expect(subject.env[Grape::Env::GRAPE_REQUEST_HEADERS]).to be_a(Hash)
end
it 'sets the grape.request.params environment' do
subject.call(Rack::QUERY_STRING => 'test=1', Rack::RACK_INPUT => StringIO.new)
expect(subject.env[Grape::Env::GRAPE_REQUEST_PARAMS]).to be_a(Hash)
end
end
end