Sha256: 5077c7edda82d0cbe80463bcbc1103bb16f98418436ac8cb1624644c82f04f85

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'fakefs/safe'
require 'rack/logs/viewer'

describe 'Rack::Logs::Viewer' do
  let(:config) { instance_double "Rack::Logs::Config", pattern: '*.doge', log_dir: './tmp' }

  describe '#initialize' do
    it 'takes a configuration' do
      Rack::Logs::Viewer.new config
    end
  end

  describe '#call env' do
    let(:viewer)   { Rack::Logs::Viewer.new config }
    let(:response) { viewer.call({}) }

    before do
      FakeFS.activate!
      FileUtils.mkdir_p('./tmp')
      File.open('./tmp/not_log.txt','w') { |file| file.write 'Nothing to see here' }
      File.open('./tmp/my_log.doge','w') { |file| file.write 'Much log, such information' }
    end
    after do
      FakeFS.deactivate!
    end

    it 'returns a rack response' do
      expect(response[0]).to be_a Fixnum
      expect(response[1]).to be_a Hash
      expect(response[1].keys).to include 'Content-Type'
      expect(response[2].respond_to? :each).to be true
    end
    it 'returns the contents of the logs' do
      expect(response[2]).to eq ["## tmp/my_log.doge\n\nMuch log, such information"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-logs-0.0.1 spec/unit/rack/logs/viewer_spec.rb