Skip to content

Commit

Permalink
Add a spec to test case-insensitivity with headers_to_save
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Nov 23, 2016
1 parent 29fd8ac commit 8d2ebe8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions spec/models/agents/http_status_agent_spec.rb
Expand Up @@ -79,7 +79,7 @@ def created_events
let(:successful_url) { "http://#{SecureRandom.uuid}/" }

let(:status_code) { 200 }
let(:header) { SecureRandom.uuid }
let(:header) { 'X-Some-Header' }
let(:header_value) { SecureRandom.uuid }

before do
Expand Down Expand Up @@ -317,7 +317,7 @@ def created_events

end

describe "with a header specified" do
describe "with a response with a header" do
before do
stub_request(:get, successful_url).to_return(
status: status_code,
Expand All @@ -329,13 +329,27 @@ def created_events
Event.new(payload: { url: successful_url, headers_to_save: header })
end

it "should return the header value" do
it "should save the header value according to headers_to_save" do
agent.receive events
event = created_events.last
expect(event[:payload]['headers']).not_to be_nil
expect(event[:payload]['headers'][header]).to eq(header_value)
end

context "regarding case-insensitivity" do
let(:event_with_a_successful_ping) do
super().tap { |event|
event.payload[:headers_to_save].swapcase!
}
end

it "should save the header value according to headers_to_save" do
agent.receive events
event = created_events.last
expect(event[:payload]['headers']).not_to be_nil
expect(event[:payload]['headers'][header.swapcase]).to eq(header_value)
end
end
end

describe "with existing and non-existing headers specified" do
Expand Down

0 comments on commit 8d2ebe8

Please sign in to comment.