Sha256: b516b88cda3ca90e95df874690bbe0ab52a05bd8e0434b26421124109db75672

Contents?: true

Size: 1.11 KB

Versions: 14

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

14 entries across 14 versions & 1 rubygems

Version Path
saddle-0.0.23 spec/requester/retry_spec.rb
saddle-0.0.22 spec/requester/retry_spec.rb
saddle-0.0.21 spec/requester/retry_spec.rb
saddle-0.0.19 spec/requester/retry_spec.rb
saddle-0.0.18 spec/requester/retry_spec.rb
saddle-0.0.17 spec/requester/retry_spec.rb
saddle-0.0.16 spec/requester/retry_spec.rb
saddle-0.0.15 spec/requester/retry_spec.rb
saddle-0.0.14 spec/requester/retry_spec.rb
saddle-0.0.12 spec/requester/retry_spec.rb
saddle-0.0.11 spec/requester/retry_spec.rb
saddle-0.0.10 spec/requester/retry_spec.rb
saddle-0.0.7 spec/requester/retry_spec.rb
saddle-0.0.6 spec/requester/retry_spec.rb