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 b3697e6 commit 1e04149
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions spec/grape/dsl/inside_route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,14 @@ def initialize
expect(subject.sendfile).to eq file_response
end

it 'does not change the Cache-Control header' do
expect(subject.header[Rack::CACHE_CONTROL]).to eq 'cache'
it 'set the correct headers' do
expect(subject.header).to match(
Rack::CACHE_CONTROL => 'cache',
Rack::CONTENT_LENGTH => 123,
Grape::Http::Headers::TRANSFER_ENCODING => 'base64'
)
end

it 'does not change the Content-Length header' do
expect(subject.header[Rack::CONTENT_LENGTH]).to eq 123
end

it 'does not change the Transfer-Encoding header' do
subject.sendfile file_path

expect(subject.header[Grape::Http::Headers::TRANSFER_ENCODING]).to eq 'base64'
end
end

context 'as object' do
Expand Down Expand Up @@ -308,7 +303,7 @@ def initialize

it 'returns default' do
expect(subject.stream).to be_nil
expect(subject.header[Rack::CACHE_CONTROL]).to be_nil
expect(subject.header).to be_empty
end
end

Expand Down

0 comments on commit 1e04149

Please sign in to comment.