Skip to content

Commit

Permalink
Use match operator instead of multiple examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ericproulx committed Sep 25, 2024
1 parent b7c284e commit b3697e6
Showing 1 changed file with 4 additions and 52 deletions.
56 changes: 4 additions & 52 deletions spec/grape/dsl/inside_route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,42 +262,15 @@ def initialize
subject.header Rack::CACHE_CONTROL, 'cache'
subject.header Rack::CONTENT_LENGTH, 123
subject.header Grape::Http::Headers::TRANSFER_ENCODING, 'base64'
end

it 'emits no deprecation warnings' do
expect(Grape.deprecator).not_to receive(:warn)

subject.stream file_path
end

it 'returns file body wrapped in StreamResponse' do
subject.stream file_path

expect(subject.stream).to eq file_response
end

it 'sets Cache-Control header to no-cache' do
subject.stream file_path

expect(subject.header[Rack::CACHE_CONTROL]).to eq 'no-cache'
end

it 'does not change Cache-Control header' do
subject.stream

expect(subject.header[Rack::CACHE_CONTROL]).to eq 'cache'
end

it 'sets Content-Length header to nil' do
subject.stream file_path

expect(subject.header[Rack::CONTENT_LENGTH]).to be_nil
end

it 'sets Transfer-Encoding header to nil' do
subject.stream file_path

expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to be_nil
it 'sets only the cache-control header' do
expect(subject.header).to match(Rack::CACHE_CONTROL => 'no-cache')
end
end

Expand All @@ -312,36 +285,15 @@ def initialize
subject.header Rack::CACHE_CONTROL, 'cache'
subject.header Rack::CONTENT_LENGTH, 123
subject.header Grape::Http::Headers::TRANSFER_ENCODING, 'base64'
end

it 'emits no deprecation warnings' do
expect(Grape.deprecator).not_to receive(:warn)

subject.stream stream_object
end

it 'returns value wrapped in StreamResponse' do
subject.stream stream_object

expect(subject.stream).to eq stream_response
end

it 'sets Cache-Control header to no-cache' do
subject.stream stream_object

expect(subject.header[Rack::CACHE_CONTROL]).to eq 'no-cache'
end

it 'sets Content-Length header to nil' do
subject.stream stream_object

expect(subject.header[Rack::CONTENT_LENGTH]).to be_nil
end

it 'sets Transfer-Encoding header to nil' do
subject.stream stream_object

expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to be_nil
it 'set only the cache-control header' do
expect(subject.header).to match(Rack::CACHE_CONTROL => 'no-cache')
end
end

Expand Down

0 comments on commit b3697e6

Please sign in to comment.