Sha256: 33cc3fad3bd6fe34106706b5bd8fb19f82a4a9eeb2c75b4b2d6971515b360f30

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require 'saddle'
require 'saddle/middleware/logging/airbrake'
require 'saddle/middleware/logging/statsd'

describe Saddle::Client do

  context "Test middlewares" do

    before :each do
      @stubs = Faraday::Adapter::Test::Stubs.new do |stub|
        stub.get('/test') {
          [
            200,
            {},
            'Party on!',
          ]
        }
      end

      @default_client = Saddle::Client.create(:stubs => @stubs)
    end


    it "test logging/airbrake" do
      class AirbrakeClient < Saddle::Client
        add_middleware({
          :klass => Saddle::Middleware::Logging::AirbrakeLogger,
        })
      end

      client = AirbrakeClient.create(:stubs => @stubs)
      client.requester.get('/test').should == 'Party on!'
    end

    it "test logging/statsd" do
      class StatsdClient < Saddle::Client
        add_middleware({
          :klass => Saddle::Middleware::Logging::StatsdLogger,
          :args => ['127.0.0.1'],
        })
      end

      client = StatsdClient.create(:stubs => @stubs)
      client.requester.get('/test').should == 'Party on!'
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saddle-0.0.23 spec/middleware_spec.rb
saddle-0.0.22 spec/middleware_spec.rb
saddle-0.0.21 spec/middleware_spec.rb
saddle-0.0.19 spec/middleware_spec.rb
saddle-0.0.18 spec/middleware_spec.rb