Sha256: c34a13b01afe650b0ec10a0ea54ca5139e6e80508d56f3f06e461a79732e162d

Contents?: true

Size: 865 Bytes

Versions: 16

Compression:

Stored size: 865 Bytes

Contents

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

describe HTTParty::Logger::ApacheLogger do
  describe "#format" do
    it "formats a response in a style that resembles apache's access log" do
      request_time = Time.new.strftime("%Y-%m-%d %H:%M:%S %z")
      log_message = "[HTTParty] [#{request_time}] 302 \"GET http://my.domain.com/my_path\" - "

      request_double  = double(
        :http_method => Net::HTTP::Get,
        :path => "http://my.domain.com/my_path"
      )
      response_double = double(
        :code => 302,
        :[]   => nil
      )

      logger_double = double
      logger_double.should_receive(:info).with(log_message)

      subject = described_class.new(logger_double, :info)
      subject.current_time = request_time
      subject.format(request_double, response_double)
    end
  end
end

Version data entries

16 entries across 15 versions & 5 rubygems

Version Path
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/2.6.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/httparty-0.13.1/spec/httparty/logger/apache_logger_spec.rb
httparty-0.13.1 spec/httparty/logger/apache_logger_spec.rb
yoyle439587298-0.13.0 spec/httparty/logger/apache_logger_spec.rb
httparty-0.13.0 spec/httparty/logger/apache_logger_spec.rb
httparty-0.12.0 spec/httparty/logger/apache_logger_spec.rb