Sha256: b1f195eb763a5c416aa2017a6f7ce9f994b9f55b0c03416ac6df8c338cbf5d48

Contents?: true

Size: 781 Bytes

Versions: 4

Compression:

Stored size: 781 Bytes

Contents

require 'spec_helper'
require 'logger'
require 'tempfile'

describe Clearsale::LoggerFormatterFilter do
  let(:tmp_file) { Tempfile.new('tagfilter') }
  let(:logger)   { Logger.new tmp_file }

  let(:order_xml)          { File.read('./spec/fixtures/clearsale.xml').chomp }
  let(:filtered_order_xml) { File.read('./spec/fixtures/filtered_clearsale.xml').chomp }

  before do
    described_class.tags_to_filter = %w(CardNumber CardBin)
    logger.formatter = described_class.new_instance do |severity, datetime, progname, filtered_msg|
      "#{severity} #{filtered_msg}"
    end
  end

  after do
    tmp_file.close
  end

  it "filters the configured tag names" do
    logger.info(order_xml)
    tmp_file.rewind
    tmp_file.read.should == "INFO #{filtered_order_xml}"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clearsale-0.1.6 spec/logger_formatter_spec.rb
clearsale-0.1.5 spec/logger_formatter_spec.rb
clearsale-0.1.4 spec/logger_formatter_spec.rb
clearsale-0.1.3 spec/logger_formatter_spec.rb