spec/rapidash/http_client_spec.rb in rapidash-0.3.1 vs spec/rapidash/http_client_spec.rb in rapidash-0.4.0

- old
+ new

@@ -21,21 +21,21 @@ let!(:subject) { HTTPTester.new } describe ".connection" do it "should create a Faraday object" do subject.site = "http://example.com/" - subject.connection.class.should eql(Faraday::Connection) + expect(subject.connection.class).to eql(Faraday::Connection) end it "should raise Configuration error if site nil" do expect { subject.connection }.to raise_error(Rapidash::ConfigurationError) end it "should use the site variable if set" do - Faraday.should_receive(:new).with("http://example.com/") + allow(Faraday).to receive(:new).with("http://example.com/") subject.site = "http://example.com/" subject.connection end end @@ -61,10 +61,21 @@ end end it "should call response" do response = double(:body => "response") - subject.connection.should_receive(:run_request).with(:get, "http://example.com/foo", nil, nil).and_return(response) + allow(subject.connection).to receive(:run_request).with(:get, "http://example.com/foo", nil, nil).and_return(response) subject.request(:get, "foo") end + + describe "default options" do + let!(:subject) { HTTPTester.new(request_default_options: { header: { user_agent: 'New app v1.0'} } ) } + + it "should provide default headers in the request" do + response = double(:body => "response") + allow(subject.connection).to receive(:run_request).with(:get, "http://example.com/foo", nil, {:user_agent=>"New app v1.0"}).and_return(response) + subject.request(:get, "foo") + end + end + end end