Sha256: f53949ec2321d2fa0237cc74363c18740ced86b167f13f2e075097becb6c3c06

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'
module Alf
  shared_examples_for "A valid Logs::Reader instance" do

    specify{ reader.should be_a(::Alf::Logs::Reader) }
    
    it "should yield a pseudo-relation" do
      reader.all?{|tuple| tuple.is_a?(Hash)}.should be_true
    end
    
  end
  describe Logs::Reader do
    
    let(:input){ _("apache_combined.log", __FILE__) }
    
    describe "when called on a reader directly" do
      let(:reader){
        ::Alf::Logs::Reader.new(input)
      }
      it_should_behave_like "A valid Logs::Reader instance"
    end
    
    describe "when called through registered one" do
      let(:reader){
        ::Alf::Reader.reader(input)
      }
      it_should_behave_like "A valid Logs::Reader instance"
    end
    
    describe "when called through factory method" do
      let(:reader){
        ::Alf::Reader.logs(input)
      }
      it_should_behave_like "A valid Logs::Reader instance"
    end
    
    describe "the auto-detect feature" do
      let(:reader){ ::Alf::Logs::Reader.new(nil,nil,:file_format => nil) }
      let(:relation){ reader.to_rel }
      
      describe "on postgresql.log" do
        pending("postgresql log format seems broken") {
          before{ reader.pipe(_("postgresql.log", __FILE__)) }
          it_should_behave_like "A valid Logs::Reader instance"
          specify{ relation.should_not be_empty }
        }
      end
      
      describe "on apache_combined.log" do
        before{ reader.pipe(_("apache_combined.log", __FILE__)) }
        it_should_behave_like "A valid Logs::Reader instance"
        specify{ relation.should_not be_empty }
      end
        
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/logs/test_reader.rb