rackamole 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/History.txt +4 -0
  2. data/README.txt +93 -0
  3. data/Rakefile +28 -0
  4. data/aaa.txt +36 -0
  5. data/bin/rackamole +8 -0
  6. data/images/mole_logo.png +0 -0
  7. data/images/mole_logo.psd +0 -0
  8. data/images/mole_logo_small.png +0 -0
  9. data/images/mole_logo_small.psd +0 -0
  10. data/lib/rackamole.rb +46 -0
  11. data/lib/rackamole/interceptor.rb +20 -0
  12. data/lib/rackamole/logger.rb +121 -0
  13. data/lib/rackamole/mole.rb +134 -0
  14. data/lib/rackamole/store/log.rb +55 -0
  15. data/lib/rackamole/store/mongo.rb +104 -0
  16. data/samples/rails/moled/README +243 -0
  17. data/samples/rails/moled/Rakefile +10 -0
  18. data/samples/rails/moled/app/controllers/application_controller.rb +13 -0
  19. data/samples/rails/moled/app/controllers/fred_controller.rb +4 -0
  20. data/samples/rails/moled/app/helpers/application_helper.rb +3 -0
  21. data/samples/rails/moled/app/views/fred/index.html.erb +1 -0
  22. data/samples/rails/moled/config/boot.rb +110 -0
  23. data/samples/rails/moled/config/database.yml +22 -0
  24. data/samples/rails/moled/config/environment.rb +45 -0
  25. data/samples/rails/moled/config/environments/development.rb +17 -0
  26. data/samples/rails/moled/config/environments/production.rb +28 -0
  27. data/samples/rails/moled/config/environments/test.rb +28 -0
  28. data/samples/rails/moled/config/initializers/backtrace_silencers.rb +7 -0
  29. data/samples/rails/moled/config/initializers/inflections.rb +10 -0
  30. data/samples/rails/moled/config/initializers/mime_types.rb +5 -0
  31. data/samples/rails/moled/config/initializers/new_rails_defaults.rb +19 -0
  32. data/samples/rails/moled/config/initializers/session_store.rb +15 -0
  33. data/samples/rails/moled/config/locales/en.yml +5 -0
  34. data/samples/rails/moled/config/routes.rb +43 -0
  35. data/samples/rails/moled/db/development.sqlite3 +0 -0
  36. data/samples/rails/moled/doc/README_FOR_APP +2 -0
  37. data/samples/rails/moled/log/development.log +30 -0
  38. data/samples/rails/moled/log/production.log +0 -0
  39. data/samples/rails/moled/log/server.log +0 -0
  40. data/samples/rails/moled/log/test.log +0 -0
  41. data/samples/rails/moled/public/404.html +30 -0
  42. data/samples/rails/moled/public/422.html +30 -0
  43. data/samples/rails/moled/public/500.html +30 -0
  44. data/samples/rails/moled/public/favicon.ico +0 -0
  45. data/samples/rails/moled/public/images/rails.png +0 -0
  46. data/samples/rails/moled/public/index.html +275 -0
  47. data/samples/rails/moled/public/javascripts/application.js +2 -0
  48. data/samples/rails/moled/public/javascripts/controls.js +963 -0
  49. data/samples/rails/moled/public/javascripts/dragdrop.js +973 -0
  50. data/samples/rails/moled/public/javascripts/effects.js +1128 -0
  51. data/samples/rails/moled/public/javascripts/prototype.js +4320 -0
  52. data/samples/rails/moled/public/robots.txt +5 -0
  53. data/samples/rails/moled/script/about +4 -0
  54. data/samples/rails/moled/script/console +3 -0
  55. data/samples/rails/moled/script/dbconsole +3 -0
  56. data/samples/rails/moled/script/destroy +3 -0
  57. data/samples/rails/moled/script/generate +3 -0
  58. data/samples/rails/moled/script/performance/benchmarker +3 -0
  59. data/samples/rails/moled/script/performance/profiler +3 -0
  60. data/samples/rails/moled/script/plugin +3 -0
  61. data/samples/rails/moled/script/runner +3 -0
  62. data/samples/rails/moled/script/server +3 -0
  63. data/samples/rails/moled/test/performance/browsing_test.rb +9 -0
  64. data/samples/rails/moled/test/test_helper.rb +38 -0
  65. data/samples/sinatra/moled.rb +20 -0
  66. data/spec/expected_results/mole_exception.log +17 -0
  67. data/spec/expected_results/mole_feature.log +15 -0
  68. data/spec/expected_results/mole_perf.log +16 -0
  69. data/spec/rackamole/interceptor_spec.rb +33 -0
  70. data/spec/rackamole/logger_spec.rb +55 -0
  71. data/spec/rackamole/mole_spec.rb +90 -0
  72. data/spec/rackamole/store/log_spec.rb +54 -0
  73. data/spec/rackamole/store/mongo_spec.rb +120 -0
  74. data/spec/rackamole_spec.rb +20 -0
  75. data/spec/spec_helper.rb +8 -0
  76. data/tasks/ann.rake +80 -0
  77. data/tasks/bones.rake +20 -0
  78. data/tasks/gem.rake +201 -0
  79. data/tasks/git.rake +40 -0
  80. data/tasks/notes.rake +27 -0
  81. data/tasks/post_load.rake +34 -0
  82. data/tasks/rdoc.rake +51 -0
  83. data/tasks/rubyforge.rake +55 -0
  84. data/tasks/setup.rb +292 -0
  85. data/tasks/spec.rake +54 -0
  86. data/tasks/svn.rake +47 -0
  87. data/tasks/test.rake +40 -0
  88. data/tasks/zentest.rake +36 -0
  89. metadata +198 -0
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/dbconsole'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/destroy'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/benchmarker'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/profiler'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/plugin'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/runner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/server'
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionController::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Transactional fixtures accelerate your tests by wrapping each test method
7
+ # in a transaction that's rolled back on completion. This ensures that the
8
+ # test database remains unchanged so your fixtures don't have to be reloaded
9
+ # between every test method. Fewer database queries means faster tests.
10
+ #
11
+ # Read Mike Clark's excellent walkthrough at
12
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
+ #
14
+ # Every Active Record database supports transactions except MyISAM tables
15
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
16
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
17
+ # is recommended.
18
+ #
19
+ # The only drawback to using transactional fixtures is when you actually
20
+ # need to test transactions. Since your test is bracketed by a transaction,
21
+ # any transactions started in your code will be automatically rolled back.
22
+ self.use_transactional_fixtures = true
23
+
24
+ # Instantiated fixtures are slow, but give you @david where otherwise you
25
+ # would need people(:david). If you don't want to migrate your existing
26
+ # test cases which use the @david style and don't mind the speed hit (each
27
+ # instantiated fixtures translates to a database query per test method),
28
+ # then set this back to true.
29
+ self.use_instantiated_fixtures = false
30
+
31
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
+ #
33
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
+ # -- they do not yet inherit this setting
35
+ fixtures :all
36
+
37
+ # Add more helper methods to be used by all tests here...
38
+ end
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require 'rackamole'
4
+
5
+ configure do
6
+ set :sessions, true
7
+ set :environment, :development
8
+ use Rack::Reloader
9
+ use Rack::Mole, { :app_name => "My Sinatra App", :user_key => :user_name }
10
+ end
11
+
12
+ before do
13
+ session[:user_name] = "Fernand"
14
+ end
15
+
16
+ get '/fred' do
17
+ @blee = "No shit"
18
+ session[:fred] = "duh me"
19
+ "<h1>Hello World</h1>"
20
+ end
@@ -0,0 +1,17 @@
1
+ ----------------------------------------------------------------------------------------------------
2
+ MOLED EXCEPTION
3
+ App_name : "Test app"
4
+ Environment : :test
5
+ Perf_issue : false
6
+ Ip : "1.1.1.1"
7
+ Browser : "Ibrowse"
8
+ User_id : 100
9
+ User_name : "Fernand"
10
+ Request_time : 1.0
11
+ Url : "http://test_me/"
12
+ Path : "/fred"
13
+ Method : "GET"
14
+ Params : {:blee=>"\"duh\""}
15
+ Session : {:fred=>"10"}
16
+ Stack : ["Oh snap!"]
17
+ Ruby_version : "ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]"
@@ -0,0 +1,15 @@
1
+ ----------------------------------------------------------------------------------------------------
2
+ MOLED FEATURE
3
+ App_name : "Test app"
4
+ Environment : :test
5
+ Perf_issue : false
6
+ Ip : "1.1.1.1"
7
+ Browser : "Ibrowse"
8
+ User_id : 100
9
+ User_name : "Fernand"
10
+ Request_time : 1.0
11
+ Url : "http://test_me/"
12
+ Path : "/fred"
13
+ Method : "GET"
14
+ Params : {:blee=>"\"duh\""}
15
+ Session : {:fred=>"10"}
@@ -0,0 +1,16 @@
1
+ ----------------------------------------------------------------------------------------------------
2
+ MOLED PERFORMANCE
3
+ App_name : "Test app"
4
+ Environment : :test
5
+ Perf_issue : false
6
+ Ip : "1.1.1.1"
7
+ Browser : "Ibrowse"
8
+ User_id : 100
9
+ User_name : "Fernand"
10
+ Request_time : 1.0
11
+ Url : "http://test_me/"
12
+ Path : "/fred"
13
+ Method : "GET"
14
+ Params : {:blee=>"\"duh\""}
15
+ Session : {:fred=>"10"}
16
+ Performance : true
@@ -0,0 +1,33 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. spec_helper])
2
+ require 'ostruct'
3
+
4
+ describe Rackamole::Interceptor do
5
+ before( :all ) do
6
+ class Fred
7
+ def rescue_action_in_public( exception )
8
+ end
9
+
10
+ def request
11
+ @request ||= OpenStruct.new( :env => {} )
12
+ end
13
+
14
+ def self.alias_method_chain(target, feature)
15
+ alias_method "#{target}_without_#{feature}", target
16
+ alias_method target, "#{target}_with_#{feature}"
17
+ end
18
+
19
+ include Rackamole::Interceptor
20
+ end
21
+ end
22
+
23
+ it "should include the correct methods" do
24
+ Fred.instance_methods.should be_include( 'rescue_action_in_public_without_mole' )
25
+ Fred.private_instance_methods.should be_include( 'rescue_action_in_public_with_mole' )
26
+ end
27
+
28
+ it "should set the env correctly when an exception is raised" do
29
+ fred = Fred.new
30
+ fred.send( :rescue_action_in_public, "Fred" )
31
+ fred.request.env['mole.exception'].should == "Fred"
32
+ end
33
+ end
@@ -0,0 +1,55 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. spec_helper] )
2
+
3
+ require 'stringio'
4
+
5
+ describe Rackamole::Logger do
6
+ it "raises an error if the email addresses passed in is empty" do
7
+ lambda { Rackamole::Logger.new( { :email_alerts_to => [] } ) }.should raise_error( Rackamole::Logger::ConfigurationError )
8
+ end
9
+
10
+ it "configures an email appender if :email_alerts is set" do
11
+ l = Rackamole::Logger.new( { :logger_name => "Test2", :email_alerts_to => "fernand@invalid.address", :email_alert_level => :off })
12
+ l.email_appender.should_not == nil
13
+ end
14
+
15
+ it "does not configure an email appender if :email_alerts is not set" do
16
+ l = Rackamole::Logger.new( { :logger_name => "Test3" })
17
+ lambda { l.email_appender }.should raise_error( Rackamole::Logger::ConfigurationError )
18
+ end
19
+
20
+ it "raises an error if an invalid object is passed in for the :log_file" do
21
+ lambda { l = Rackamole::Logger.new( { :log_file => Object.new } ) }.should raise_error( Rackamole::Logger::ConfigurationError )
22
+ end
23
+
24
+ it "logs to an IO stream if given" do
25
+ io = StringIO.new
26
+ l = Rackamole::Logger.new( { :log_file => io, :logger_name => "Test4" })
27
+ l.info "This is a test io message"
28
+ io.string.split("\n").should have(1).item
29
+ io.string.should =~ /This is a test io message/
30
+ io.string.should =~ /INFO/
31
+ end
32
+
33
+ it "logs to a file if given a file name to log to" do
34
+ log_file = "/tmp/mole_logger_test.log"
35
+ FileUtils.rm( log_file ) if File.exists?( log_file )
36
+ l = Rackamole::Logger.new({ :log_file => log_file, :logger_name => "Test5" })
37
+ l.info "This is a test log file message"
38
+
39
+ log_lines = IO.readlines(log_file)
40
+
41
+ log_lines.should have(1).items
42
+ log_lines.first.should =~ /This is a test log file message/
43
+ log_lines.first.should =~ /INFO/
44
+ end
45
+
46
+ it "creates a logger from another logger" do
47
+ io = StringIO.new
48
+ l = Rackamole::Logger.new( { :log_file => io, :logger_name => 'Mole' } )
49
+ child_l = l.for(Rack::Mole)
50
+
51
+ child_l.info "This is a child log message"
52
+ io.string.should =~ /This is a child log message/
53
+ io.string.should =~ /INFO/
54
+ end
55
+ end
@@ -0,0 +1,90 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. spec_helper])
2
+ require 'actionpack'
3
+
4
+ describe Rack::Mole do
5
+ include Rack::Test::Methods
6
+
7
+ before :each do
8
+ @response = [ 200, {"Content-Type" => "text/plain"}, ["success"] ]
9
+ end
10
+
11
+ class TestStore
12
+ attr_accessor :mole_result
13
+
14
+ def mole( args )
15
+ @mole_result = args
16
+ end
17
+ end
18
+
19
+ def app( opts={} )
20
+ response = @response
21
+ @app ||= Rack::Builder.new do
22
+ use Rack::Lint
23
+ use Rack::Mole, opts
24
+ run lambda { |env| response }
25
+ end
26
+ end
27
+
28
+ describe 'moling a request' do
29
+ before :each do
30
+ @test_store = TestStore.new
31
+ @test_env = { 'rack.session' => { :user_id => 100 }, 'HTTP_X_FORWARDED_FOR' => '1.1.1.1', 'HTTP_USER_AGENT' => "IBrowse" }
32
+ app(
33
+ :app_name => "Test App",
34
+ :environment => :test,
35
+ :perf_threshold => 0.1,
36
+ :user_key => { :session_key => :user_id, :extractor => lambda{ |k| "Test user #{k}"} },
37
+ :store => @test_store )
38
+ end
39
+
40
+ it "should set the mole meta correctly" do
41
+ get "/", nil, @test_env
42
+ @test_store.mole_result[:app_name].should == "Test App"
43
+ @test_store.mole_result[:environment].should == :test
44
+ @test_store.mole_result[:user_id].should == 100
45
+ @test_store.mole_result[:user_name].should == 'Test user 100'
46
+ @test_store.mole_result[:ip].should == '1.1.1.1'
47
+ @test_store.mole_result[:browser].should == 'IBrowse'
48
+ @test_store.mole_result[:method].should == 'GET'
49
+ @test_store.mole_result[:url].should == 'http://example.org/'
50
+ @test_store.mole_result[:path].should == '/'
51
+ @test_store.mole_result[:perf_issue].should == false
52
+ @test_store.mole_result[:params].should be_nil
53
+ @test_store.mole_result[:session].should_not be_nil
54
+ @test_store.mole_result[:session].should == { :user_id => '100' }
55
+ end
56
+
57
+ it "mole an exception correctly" do
58
+ begin
59
+ raise 'Oh snap!'
60
+ rescue => boom
61
+ get "/", nil, { 'mole.exception' => boom, 'rack.session' => { :user_id => 100 }, 'HTTP_X_FORWARDED_FOR' => '1.1.1.1', 'HTTP_USER_AGENT' => "IBrowse" }
62
+ @test_store.mole_result[:stack].should have(4).items
63
+ end
64
+ end
65
+
66
+ it "should capture request parameters correctly" do
67
+ get "/", { :blee => 'duh' }, @test_env
68
+ @test_store.mole_result[:params].should == { :blee => "duh".to_json }
69
+ end
70
+ end
71
+
72
+ describe 'username in session' do
73
+ before :each do
74
+ @test_store = TestStore.new
75
+ @test_env = { 'rack.session' => { :user_name => "Fernand" } }
76
+ app(
77
+ :app_name => "Test App",
78
+ :environment => :test,
79
+ :perf_threshold => 0.1,
80
+ :user_key => :user_name,
81
+ :store => @test_store )
82
+ end
83
+
84
+ it "should mole the user correctly" do
85
+ get "/", nil, @test_env
86
+ @test_store.mole_result[:user_id].should be_nil
87
+ @test_store.mole_result[:user_name].should == 'Fernand'
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
+ require 'mongo/util/ordered_hash'
3
+
4
+ describe Rackamole::Store::Log do
5
+ describe "#mole" do
6
+ before( :each ) do
7
+ @test_file = '/tmp/test_mole.log'
8
+ File.delete( @test_file ) if File.exists?( @test_file )
9
+
10
+ @store = Rackamole::Store::Log.new( @test_file )
11
+
12
+ @args = OrderedHash.new
13
+ @args[:app_name] = "Test app"
14
+ @args[:environment] = :test
15
+ @args[:perf_issue] = false
16
+ @args[:ip] = "1.1.1.1"
17
+ @args[:browser] = "Ibrowse"
18
+ @args[:user_id] = 100
19
+ @args[:user_name] = "Fernand"
20
+ @args[:request_time] = 1.0
21
+ @args[:url] = "http://test_me/"
22
+ @args[:path] = "/fred"
23
+ @args[:method] = 'GET'
24
+ @args[:params] = { :blee => "duh".to_json }
25
+ @args[:session] = { :fred => 10.to_json }
26
+ end
27
+
28
+ it "should mole a feature correctly" do
29
+ @store.mole( @args )
30
+ results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
31
+ expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_feature.log] ) )
32
+ expected.should == results
33
+ end
34
+
35
+ it "should mole an exception correctly" do
36
+ @args[:stack] = [ 'Oh snap!' ]
37
+ @args[:ruby_version] = 'ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]'
38
+
39
+ @store.mole( @args )
40
+ results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
41
+ expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_exception.log] ) )
42
+ expected.should == results
43
+ end
44
+
45
+ it "should mole a performance issue correctly" do
46
+ @args[:performance] = true
47
+ @store.mole( @args )
48
+ results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
49
+ expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_perf.log] ) )
50
+ expected.should == results
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,120 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
+ require 'mongo/util/ordered_hash'
3
+
4
+ describe Rackamole::Store::Log do
5
+
6
+ describe "#mole" do
7
+ before( :each ) do
8
+ @store = Rackamole::Store::Mongo.new( :host => 'localhost', :port => 27017, :database => 'test_mole_mdb' )
9
+ @store.reset!
10
+
11
+ @args = OrderedHash.new
12
+ @args[:app_name] = "Test app"
13
+ @args[:environment] = :test
14
+ @args[:perf_issue] = false
15
+ @args[:ip] = "1.1.1.1"
16
+ @args[:browser] = "Ibrowse"
17
+ @args[:user_id] = 100
18
+ @args[:user_name] = "Fernand"
19
+ @args[:request_time] = 1.0
20
+ @args[:url] = "http://test_me/"
21
+ @args[:path] = "/fred"
22
+ @args[:method] = 'GET'
23
+ @args[:params] = { :blee => "duh".to_json }
24
+ @args[:session] = { :fred => 10.to_json }
25
+ end
26
+
27
+ it "should mole a feature correctly" do
28
+ @store.mole( @args )
29
+ @store.features.count.should == 1
30
+ @store.logs.count.should == 1
31
+
32
+ feature = @store.features.find_one( {} )
33
+ feature.should_not be_nil
34
+ feature['app_name'].should == 'Test app'
35
+ feature['context'].should == '/fred'
36
+ feature['created_at'].should_not be_nil
37
+ feature['updated_at'].should_not be_nil
38
+
39
+ log = @store.logs.find_one( {} )
40
+ log.should_not be_nil
41
+ log['params'].should == { 'blee' => 'duh'.to_json }
42
+ log['ip'].should == '1.1.1.1'
43
+ log['browser'].should == 'Ibrowse'
44
+ log['environment'].should == :test
45
+ log['path'].should == '/fred'
46
+ log['url'].should == 'http://test_me/'
47
+ log['method'].should == 'GET'
48
+ log['session'].should == { 'fred' => '10' }
49
+ log['user_name'].should == 'Fernand'
50
+ log['user_id'].should == 100
51
+ log['request_time'].should == 1.0
52
+ log['perf_issue'].should == false
53
+ log['created_at'].should_not be_nil
54
+ log['updated_at'].should_not be_nil
55
+ @store.connection.dereference( log['feature'] )['app_name'].should == 'Test app'
56
+ end
57
+
58
+ it "should mole a rails feature correctly" do
59
+ @args[:path] = '/fred/blee/duh'
60
+ @args[:route_info] = { :controller => 'fred', :action => 'blee', :id => 'duh' }
61
+ @store.mole( @args )
62
+
63
+ @store.features.count.should == 1
64
+ @store.logs.count.should == 1
65
+
66
+ feature = @store.features.find_one( {} )
67
+ feature.should_not be_nil
68
+ feature['controller'].should == 'fred'
69
+ feature['action'].should == 'blee'
70
+ feature['context'].should be_nil
71
+
72
+ log = @store.logs.find_one( {} )
73
+ log.should_not be_nil
74
+ log['route_info'].should_not be_nil
75
+ end
76
+
77
+ it "should reuse an existing feature" do
78
+ @store.mole( @args )
79
+ @store.mole( @args )
80
+
81
+ @store.features.count.should == 1
82
+ @store.logs.count.should == 2
83
+ end
84
+
85
+ it "should mole perf correctly" do
86
+ @args[:perf_issue] = true
87
+ @store.mole( @args )
88
+
89
+ @store.features.count.should == 1
90
+ @store.logs.count.should == 1
91
+
92
+ feature = @store.features.find_one( {} )
93
+ feature.should_not be_nil
94
+
95
+ log = @store.logs.find_one( {} )
96
+ log.should_not be_nil
97
+ log['perf_issue'].should == true
98
+ end
99
+
100
+ it 'should mole an exception correctly' do
101
+ @args[:exception] = ['fred']
102
+ @store.mole( @args )
103
+
104
+ @store.features.count.should == 1
105
+ @store.logs.count.should == 1
106
+
107
+ feature = @store.features.find_one( {} )
108
+ feature.should_not be_nil
109
+
110
+ log = @store.logs.find_one( {} )
111
+ log.should_not be_nil
112
+ log['exception'].should == ['fred']
113
+ end
114
+
115
+ it 'should keep count an similar exceptions or perf issues' do
116
+ pending "NYI"
117
+ end
118
+ end
119
+
120
+ end