Sha256: ac795dbb1f799a3f428a55ec39b8921c20d9791fec38804773dd6691faee80eb

Contents?: true

Size: 1.71 KB

Versions: 8

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe RequestLogAnalyzer::Controller do

  include RequestLogAnalyzerSpecHelper

  # it "should include the file format module" do
  #   controller = RequestLogAnalyzer::Controller.new(:rails)
  #   (class << controller; self; end).ancestors.include?(RequestLogAnalyzer::FileFormat::Rails)
  # end

  it "should call the aggregators when run" do
    file_format = RequestLogAnalyzer::FileFormat.load(:rails)
    source      = RequestLogAnalyzer::Source::LogFile.new(file_format, :source_files => log_fixture(:rails_1x))  
    controller  = RequestLogAnalyzer::Controller.new(source)
    
    mock_aggregator = mock('aggregator')
    mock_aggregator.should_receive(:prepare).once.ordered
    mock_aggregator.should_receive(:aggregate).with(an_instance_of(RequestLogAnalyzer::Request)).at_least(:twice).ordered
    mock_aggregator.should_receive(:finalize).once.ordered
    mock_aggregator.should_receive(:report).once.ordered
    
    another_mock_aggregator = mock('another aggregator')
    another_mock_aggregator.should_receive(:prepare).once.ordered
    another_mock_aggregator.should_receive(:aggregate).with(an_instance_of(RequestLogAnalyzer::Request)).at_least(:twice).ordered
    another_mock_aggregator.should_receive(:finalize).once.ordered  
    another_mock_aggregator.should_receive(:report).once.ordered  

    
    controller.aggregators << mock_aggregator << another_mock_aggregator
    controller.run!
  end
  
  it "should run well from the command line" do
    temp_file = "#{File.dirname(__FILE__)}/fixtures/temp.txt"
    system("#{File.dirname(__FILE__)}/../bin/request-log-analyzer #{log_fixture(:rails_1x)} > #{temp_file}").should be_true
    File.unlink(temp_file)
  end
  
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
wvanbergen-request-log-analyzer-1.0.0 spec/controller_spec.rb
wvanbergen-request-log-analyzer-1.0.1 spec/controller_spec.rb
wvanbergen-request-log-analyzer-1.0.2 spec/controller_spec.rb
wvanbergen-request-log-analyzer-1.0.3 spec/controller_spec.rb
wvanbergen-request-log-analyzer-1.0.4 spec/controller_spec.rb
request-log-analyzer-1.0.4 spec/controller_spec.rb
request-log-analyzer-1.0.3 spec/controller_spec.rb
request-log-analyzer-1.0.2 spec/controller_spec.rb