Skip to content

Commit

Permalink
Just checking that _plain_request works with custom headers too
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjeffries committed Dec 12, 2017
1 parent 364b5bf commit 7f74281
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/lib/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ class DummyExample < Flexirest::Base
EmptyExample._request("http://api.example.com/v1", :get, {}, {headers: {"X-Something": "foo/bar"}})
end

it "passes headers if the response is unparsed" do
stub_request(:get, "http://api.example.com/v1").
with(headers: {'Accept'=>'application/hal+json, application/json;q=0.5', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Connection'=>'Keep-Alive', 'Content-Type'=>'application/x-www-form-urlencoded', 'X-Something'=>'foo/bar', 'User-Agent'=>/Flexirest\//}).
to_return(status: 200, body: "", headers: {})
EmptyExample._plain_request("http://api.example.com/v1", :get, {}, {headers: {"X-Something": "foo/bar"}})
end

it "runs callbacks as usual" do
expect_any_instance_of(Flexirest::Request).to receive(:do_request).with(any_args).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, response_headers:{}, body:"{\"first_name\":\"Billy\"}")))
expect(EmptyExample).to receive(:_callback_request).with(any_args).exactly(2).times
Expand Down

0 comments on commit 7f74281

Please sign in to comment.