Sha256: b57c5b493578a5db93e3edacb9e9bb729f124cfa494e5b1691d9303736bf75c0

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))

RSpec.describe HTTParty::Logger do
  describe ".build" do
    subject { HTTParty::Logger }

    it "defaults level to :info" do
      logger_double = double
      expect(subject.build(logger_double, nil, nil).level).to eq(:info)
    end

    it "defaults format to :apache" do
      logger_double = double
      expect(subject.build(logger_double, nil, nil)).to be_an_instance_of(HTTParty::Logger::ApacheFormatter)
    end

    it "builds :curl style logger" do
      logger_double = double
      expect(subject.build(logger_double, nil, :curl)).to be_an_instance_of(HTTParty::Logger::CurlFormatter)
    end

    it "builds :custom style logger" do
      CustomFormatter = Class.new(HTTParty::Logger::CurlFormatter)
      HTTParty::Logger.add_formatter(:custom, CustomFormatter)

      logger_double = double
      expect(subject.build(logger_double, nil, :custom)).
        to be_an_instance_of(CustomFormatter)
    end
    it "raises error when formatter exists" do
      CustomFormatter2= Class.new(HTTParty::Logger::CurlFormatter)
      HTTParty::Logger.add_formatter(:custom2, CustomFormatter2)

      expect{ HTTParty::Logger.add_formatter(:custom2, CustomFormatter2) }.
        to raise_error HTTParty::Error
    end
  end
end

Version data entries

17 entries across 16 versions & 3 rubygems

Version Path
httparty-0.16.2 spec/httparty/logger/logger_spec.rb
httparty-0.16.1 spec/httparty/logger/logger_spec.rb
httparty-0.16.0 spec/httparty/logger/logger_spec.rb
httparty-0.15.7 spec/httparty/logger/logger_spec.rb
httparty-0.15.6 spec/httparty/logger/logger_spec.rb
httparty-0.15.5 spec/httparty/logger/logger_spec.rb
httparty-0.15.4 spec/httparty/logger/logger_spec.rb
httparty-0.15.3 spec/httparty/logger/logger_spec.rb
httparty-0.15.2 spec/httparty/logger/logger_spec.rb
httparty-0.15.1 spec/httparty/logger/logger_spec.rb
httparty-0.15.0 spec/httparty/logger/logger_spec.rb
httparty-0.14.0 spec/httparty/logger/logger_spec.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/httparty-0.13.7/spec/httparty/logger/logger_spec.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/httparty-0.13.7/spec/httparty/logger/logger_spec.rb
httparty-0.13.7 spec/httparty/logger/logger_spec.rb
httparty-0.13.6 spec/httparty/logger/logger_spec.rb
httpserious-0.13.5.lstoll1 spec/httparty/logger/logger_spec.rb