Sha256: 5a54b6c9ab6dfdd6ba85862f220359b942551e836be459dac2dc3bc2caefd852

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'saddle'



describe Saddle::Client do

  context "retry requests" do
    context "using the default client" do

      before :each do
        @stubs = Faraday::Adapter::Test::Stubs.new
        @default_client = Saddle::Client.create(:stubs => @stubs)
      end

      it "should retry properly with no params" do
        @stubs.get('/test') {
          [
            500,
            {},
            'Failure',
          ]
        }
        @stubs.get('/test') {
          [
            200,
            {},
            'Party!',
          ]
        }
        @default_client.requester.get('/test').should == 'Party!'
      end

      it "should retry properly when posting params urlencoded" do
        @stubs.post('/test', '{"a":"b","c":"d"}') {
          [
            500,
            {},
            'Failure',
          ]
        }
        @stubs.post('/test', '{"a":"b","c":"d"}') {
          [
            200,
            {},
            'Party!',
          ]
        }
        @default_client.requester.post(
          '/test',
          {'a' => 'b', 'c' => 'd'}
        ).should == 'Party!'
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
saddle-0.0.27 spec/middleware/request/retry_spec.rb
saddle-0.0.26 spec/middleware/retry_spec.rb
saddle-0.0.25 spec/middleware/retry_spec.rb