spec/httpi/httpi_spec.rb in httpi-3.0.1 vs spec/httpi/httpi_spec.rb in httpi-3.0.2

- old
+ new

@@ -31,10 +31,22 @@ HTTPI::Adapter.expects(:use=).with(:net_http) HTTPI.adapter = :net_http end end + describe ".adapter_client_setup=" do + after do + HTTPI.adapter_client_setup = nil + end + + it "sets the adapter client setup block" do + block = proc { } + HTTPI.adapter_client_setup = block + expect(HTTPI::Adapter.client_setup_block).to eq(block) + end + end + describe ".query_builder" do it "gets flat builder by default" do expect(client.query_builder).to eq(HTTPI::QueryBuilder::Flat) end context "setter" do @@ -278,9 +290,21 @@ httpclient.any_instance.expects(:request).times(2).with(:custom).returns(redirect, response) request.expects(:url=).with(URI.parse(redirect_location)) client.request(:custom, request, :httpclient) + end + + describe "client setup block present" do + around do |example| + HTTPI::Adapter.client_setup_block = proc { |client| client.base_url = 'https://google.com' } + example.run + HTTPI::Adapter.client_setup_block = nil + end + + it 'calls client setup block' do + client.request(:get, request, :httpclient) { |client| expect(client.base_url).to eq('https://google.com') } + end end end HTTPI::REQUEST_METHODS.each do |method| describe ".#{method}" do