Sha256: 0304d6b117ced23105bfb4c3dbf39313875a09a28fc0687b584e0066aab044e0

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
require 'mongo/util/ordered_hash'

describe Rackamole::Store::Log do  
  describe "#mole" do
    before( :each ) do
      @test_file = '/tmp/test_mole.log'
      File.delete( @test_file ) if File.exists?( @test_file )

      @store = Rackamole::Store::Log.new( @test_file )
        
      @args = OrderedHash.new
      @args[:app_name]     = "Test app"
      @args[:environment]  = :test
      @args[:perf_issue]   = false
      @args[:ip]           = "1.1.1.1"
      @args[:browser]      = "Ibrowse"
      @args[:user_id]      = 100
      @args[:user_name]    = "Fernand"
      @args[:request_time] = 1.0
      @args[:url]          = "http://test_me/"
      @args[:path]         = "/fred"
      @args[:method]       = 'GET'
      @args[:params]       = { :blee => "duh".to_json }
      @args[:session]      = { :fred => 10.to_json }
    end
    
    it "should mole a feature correctly" do
      @store.mole( @args )
      results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )      
      expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_feature.log] ) )    
      expected.should == results      
    end

    it "should mole an exception correctly" do
      @args[:stack] = [ 'Oh snap!' ]
      @args[:ruby_version] = 'ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]'

      @store.mole( @args )
      results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
      expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_exception.log] ) )    
      expected.should == results      
    end
    
    it "should mole a performance issue correctly" do
      @args[:performance] = true
      @store.mole( @args )
      results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
      expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_perf.log] ) )    
      expected.should == results      
    end
  end    
    
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rackamole-0.0.4 spec/rackamole/store/log_spec.rb
rackamole-0.0.3 spec/rackamole/store/log_spec.rb
rackamole-0.0.2 spec/rackamole/store/log_spec.rb
rackamole-0.0.1 spec/rackamole/store/log_spec.rb