rackamole 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY +12 -1
- data/README.rdoc +35 -35
- data/lib/rackamole.rb +1 -1
- data/lib/rackamole/alert/twitt.rb +5 -4
- data/lib/rackamole/mole.rb +40 -18
- data/lib/rackamole/store/mongo_db.rb +5 -3
- data/spec/rackamole/alert/twitt_spec.rb +3 -3
- data/spec/rackamole/mole_spec.rb +52 -5
- data/spec/rackamole/store/mongo_db_spec.rb +4 -4
- data/tasks/setup.rb +1 -1
- data/tasks/test.rake +1 -0
- metadata +3 -85
- data/a.rb +0 -18
- data/aaa.txt +0 -52
- data/images/mole_logo.png +0 -0
- data/images/mole_logo.psd +0 -0
- data/images/mole_logo_small.png +0 -0
- data/images/mole_logo_small.psd +0 -0
- data/samples/rails/moled/README +0 -243
- data/samples/rails/moled/Rakefile +0 -10
- data/samples/rails/moled/app/controllers/application_controller.rb +0 -21
- data/samples/rails/moled/app/controllers/fred_controller.rb +0 -14
- data/samples/rails/moled/app/helpers/application_helper.rb +0 -3
- data/samples/rails/moled/app/views/fred/index.html.erb +0 -1
- data/samples/rails/moled/app/views/fred/show.html.erb +0 -1
- data/samples/rails/moled/config/boot.rb +0 -110
- data/samples/rails/moled/config/database.yml +0 -22
- data/samples/rails/moled/config/environment.rb +0 -52
- data/samples/rails/moled/config/environments/development.rb +0 -17
- data/samples/rails/moled/config/environments/production.rb +0 -28
- data/samples/rails/moled/config/environments/test.rb +0 -28
- data/samples/rails/moled/config/initializers/backtrace_silencers.rb +0 -7
- data/samples/rails/moled/config/initializers/inflections.rb +0 -10
- data/samples/rails/moled/config/initializers/mime_types.rb +0 -5
- data/samples/rails/moled/config/initializers/new_rails_defaults.rb +0 -19
- data/samples/rails/moled/config/initializers/session_store.rb +0 -15
- data/samples/rails/moled/config/locales/en.yml +0 -5
- data/samples/rails/moled/config/routes.rb +0 -6
- data/samples/rails/moled/db/development.sqlite3 +0 -0
- data/samples/rails/moled/db/production.sqlite3 +0 -0
- data/samples/rails/moled/doc/README_FOR_APP +0 -2
- data/samples/rails/moled/log/development.log +0 -100
- data/samples/rails/moled/log/production.log +0 -46
- data/samples/rails/moled/log/server.log +0 -0
- data/samples/rails/moled/log/test.log +0 -0
- data/samples/rails/moled/public/404.html +0 -30
- data/samples/rails/moled/public/422.html +0 -30
- data/samples/rails/moled/public/500.html +0 -30
- data/samples/rails/moled/public/favicon.ico +0 -0
- data/samples/rails/moled/public/images/rails.png +0 -0
- data/samples/rails/moled/public/index.html +0 -275
- data/samples/rails/moled/public/javascripts/application.js +0 -2
- data/samples/rails/moled/public/javascripts/controls.js +0 -963
- data/samples/rails/moled/public/javascripts/dragdrop.js +0 -973
- data/samples/rails/moled/public/javascripts/effects.js +0 -1128
- data/samples/rails/moled/public/javascripts/prototype.js +0 -4320
- data/samples/rails/moled/public/robots.txt +0 -5
- data/samples/rails/moled/script/about +0 -4
- data/samples/rails/moled/script/console +0 -3
- data/samples/rails/moled/script/dbconsole +0 -3
- data/samples/rails/moled/script/destroy +0 -3
- data/samples/rails/moled/script/generate +0 -3
- data/samples/rails/moled/script/performance/benchmarker +0 -3
- data/samples/rails/moled/script/performance/profiler +0 -3
- data/samples/rails/moled/script/plugin +0 -3
- data/samples/rails/moled/script/runner +0 -3
- data/samples/rails/moled/script/server +0 -3
- data/samples/rails/moled/test/performance/browsing_test.rb +0 -9
- data/samples/rails/moled/test/test_helper.rb +0 -38
- data/samples/sinatra/moled.rb +0 -63
- data/samples/sinatra/public/.DS_Store +0 -0
- data/samples/sinatra/public/images/mole_logo.png +0 -0
- data/samples/sinatra/public/stylesheets/styles.css +0 -58
- data/samples/sinatra/views/index.erb +0 -14
- data/samples/sinatra/views/layout.erb +0 -23
- data/samples/sinatra/views/normal.erb +0 -1
- data/samples/sinatra/views/params.erb +0 -1
- data/samples/sinatra/views/post.erb +0 -1
- data/samples/sinatra/views/slow.erb +0 -1
- data/z_experiments/config.rb +0 -38
- data/z_experiments/config_sample.rb +0 -9
- data/z_experiments/configuration.rb +0 -5
data/HISTORY
CHANGED
|
@@ -22,4 +22,15 @@
|
|
|
22
22
|
validation problems in mongoDB. Thanks Rafael!
|
|
23
23
|
|
|
24
24
|
0.2.4
|
|
25
|
-
* Breaking off action_mailer dependencies. Now leveraging Pony for sending out email alerts.
|
|
25
|
+
* Breaking off action_mailer dependencies. Now leveraging Pony for sending out email alerts.
|
|
26
|
+
|
|
27
|
+
0.2.5
|
|
28
|
+
* Added support for excluding certain params from request or session.
|
|
29
|
+
See the params_excludes and session_excludes options.
|
|
30
|
+
|
|
31
|
+
0.2.6
|
|
32
|
+
* Added logging for response information such as status, headers and body. Body is excluded by default
|
|
33
|
+
* Added options for excluding certain mole information for being logged see mole_excludes option.
|
|
34
|
+
* Eliminated unwise defaults. From now, the option :app_name must be specified when initializing.
|
|
35
|
+
The option :db_name must also be present if the mongo store is used.
|
|
36
|
+
Keep in mind for rackamole to work with wackamole your db name must follow: mole_{app_name}_{environment}_mdb.
|
data/README.rdoc
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
==
|
|
1
|
+
== RackAmole
|
|
2
2
|
|
|
3
3
|
Observe your web applications in the wild!
|
|
4
4
|
|
|
5
|
-
== DESCRIPTION
|
|
5
|
+
== DESCRIPTION
|
|
6
6
|
|
|
7
|
-
The MOle is a rack application that monitors user interactions with your web site. We are not
|
|
8
|
-
talking about counting page hits here. The MOle tracks all the information available to capture
|
|
9
|
-
the essence of a user interaction with your application. Using the MOle, you are able to see
|
|
10
|
-
which feature is a hit or a bust. As an added bonus, the MOle also track performance and exceptions
|
|
11
|
-
that might have escaped your test suites or alpha env. To boot your managers will love you for it!
|
|
7
|
+
The MOle is a rack application that monitors user interactions with your web site. We are not
|
|
8
|
+
talking about counting page hits here. The MOle tracks all the information available to capture
|
|
9
|
+
the essence of a user interaction with your application. Using the MOle, you are able to see
|
|
10
|
+
which feature is a hit or a bust. As an added bonus, the MOle also track performance and exceptions
|
|
11
|
+
that might have escaped your test suites or alpha env. To boot your managers will love you for it!
|
|
12
12
|
|
|
13
|
-
Whether you are releasing a new application or improving on an old one, it is always a good thing
|
|
14
|
-
to know if anyone is using your application and if they are, how they are using it.
|
|
15
|
-
What features are your users most fond of and which features find their way into the abyss?
|
|
16
|
-
You will be able to rapidly assess whether or not your application is a hit and if
|
|
17
|
-
your coolest features are thought as such by your users. You will be able to elegantly record user
|
|
18
|
-
interactions and leverage these findings for the next iteration of your application.
|
|
13
|
+
Whether you are releasing a new application or improving on an old one, it is always a good thing
|
|
14
|
+
to know if anyone is using your application and if they are, how they are using it.
|
|
15
|
+
What features are your users most fond of and which features find their way into the abyss?
|
|
16
|
+
You will be able to rapidly assess whether or not your application is a hit and if
|
|
17
|
+
your coolest features are thought as such by your users. You will be able to elegantly record user
|
|
18
|
+
interactions and leverage these findings for the next iteration of your application.
|
|
19
19
|
|
|
20
20
|
== PROJECT INFORMATION
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
Developer: Fernand Galiana
|
|
23
|
+
Blog: http://www.liquidrail.com
|
|
24
|
+
Site: http://rackamole.com
|
|
25
|
+
Twitter: http://twitter.com/rackamole
|
|
26
|
+
Forum: http://groups.google.com/group/rackamole
|
|
27
|
+
Git: git://github.com/derailed/rackamole.git
|
|
28
28
|
|
|
29
|
-
== FEATURES
|
|
29
|
+
== FEATURES
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
Monitors any rack based framework such as Rails and Sinatra
|
|
32
|
+
Captures the essence of the request as well as user information
|
|
33
|
+
Tracks performance issues based on your latency threshold
|
|
34
|
+
Tracks exceptions that might occurred during a request
|
|
35
35
|
|
|
36
|
-
== REQUIREMENTS
|
|
36
|
+
== REQUIREMENTS
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
Logging
|
|
39
|
+
Hitimes
|
|
40
|
+
mongo + mongo_ext
|
|
41
|
+
Twitter4r
|
|
42
|
+
Chronic
|
|
43
|
+
Erubis
|
|
44
|
+
Pony
|
|
45
45
|
|
|
46
|
-
== INSTALL
|
|
46
|
+
== INSTALL
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
sudo gem install rackamole
|
|
49
49
|
|
|
50
|
-
== USAGE
|
|
50
|
+
== USAGE
|
|
51
51
|
|
|
52
52
|
=== Rails applications
|
|
53
53
|
|
data/lib/rackamole.rb
CHANGED
|
@@ -6,8 +6,8 @@ module Rackamole::Alert
|
|
|
6
6
|
class Twitt
|
|
7
7
|
|
|
8
8
|
# Twitt an alert
|
|
9
|
-
def self.deliver_alert( username, password, attrs )
|
|
10
|
-
@twitt ||= Twitt.new( username, password )
|
|
9
|
+
def self.deliver_alert( logger, username, password, attrs )
|
|
10
|
+
@twitt ||= Twitt.new( logger, username, password )
|
|
11
11
|
@twitt.send_alert( attrs )
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -27,10 +27,11 @@ module Rackamole::Alert
|
|
|
27
27
|
# === Params:
|
|
28
28
|
# username :: The name on the twitter account
|
|
29
29
|
# password :: The password of your twitter account
|
|
30
|
-
def initialize( username, password )
|
|
30
|
+
def initialize( logger, username, password )
|
|
31
31
|
raise "You must specify your twitter account credentials" unless username or password
|
|
32
32
|
@username = username
|
|
33
33
|
@password = password
|
|
34
|
+
@logger = logger
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
# Send out a twitt notification based of the watched features. A short message will be blasted to your twitter
|
|
@@ -62,7 +63,7 @@ module Rackamole::Alert
|
|
|
62
63
|
# =========================================================================
|
|
63
64
|
private
|
|
64
65
|
|
|
65
|
-
attr_reader :username, :password #:nodoc:
|
|
66
|
+
attr_reader :logger, :username, :password #:nodoc:
|
|
66
67
|
|
|
67
68
|
# Fetch twitter connection...
|
|
68
69
|
def twitt
|
data/lib/rackamole/mole.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'json'
|
|
|
3
3
|
require 'mongo'
|
|
4
4
|
require 'yaml'
|
|
5
5
|
|
|
6
|
+
# TODO - remove default app and db name
|
|
7
|
+
# TODO - add recording for response
|
|
6
8
|
module Rack
|
|
7
9
|
class Mole
|
|
8
10
|
|
|
@@ -43,6 +45,9 @@ module Rack
|
|
|
43
45
|
# :user_key => { :session_key => :user_id, :extractor => lambda{ |id| User.find( id ).name} }
|
|
44
46
|
# ==
|
|
45
47
|
#
|
|
48
|
+
# :mole_excludes :: Exclude some of the paramaters that the mole would normaly include. The list of
|
|
49
|
+
# customizable paramaters is: software, ip, browser type, url, path, status, headers and body.
|
|
50
|
+
# This options takes an array of symbols. Defaults to [:body].
|
|
46
51
|
# :excluded_paths:: Exclude paths that you do not wish to mole by specifying an array of regular expresssions.
|
|
47
52
|
# :param_excludes:: Exempt params from being logged to the mole. Specify an array of keys as
|
|
48
53
|
# as symbols ie [:password, :card_number].
|
|
@@ -85,12 +90,12 @@ module Rack
|
|
|
85
90
|
elapsed = Hitimes::Interval.measure do
|
|
86
91
|
begin
|
|
87
92
|
status, headers, body = @app.call( env )
|
|
88
|
-
rescue => boom
|
|
93
|
+
rescue => boom
|
|
89
94
|
env['mole.exception'] = boom
|
|
90
95
|
mole_feature( env, elapsed, status, headers, body )
|
|
91
96
|
raise boom
|
|
92
97
|
end
|
|
93
|
-
end
|
|
98
|
+
end
|
|
94
99
|
mole_feature( env, elapsed, status, headers, body )
|
|
95
100
|
return status, headers, body
|
|
96
101
|
end
|
|
@@ -119,10 +124,10 @@ module Rack
|
|
|
119
124
|
{
|
|
120
125
|
:moleable => true,
|
|
121
126
|
:log_level => :info,
|
|
122
|
-
:expiration => 60*60, # 1 hour
|
|
123
|
-
:app_name => "Moled App",
|
|
127
|
+
:expiration => 60*60, # 1 hour
|
|
124
128
|
:environment => 'development',
|
|
125
129
|
:excluded_paths => [/.?\.ico/, /.?\.png/],
|
|
130
|
+
:mole_excludes => [:body],
|
|
126
131
|
:perf_threshold => 10.0,
|
|
127
132
|
:store => Rackamole::Store::Log.new
|
|
128
133
|
}
|
|
@@ -227,12 +232,19 @@ module Rack
|
|
|
227
232
|
end
|
|
228
233
|
|
|
229
234
|
# Extract interesting information from the request
|
|
230
|
-
def mole_info( env, elapsed, status, headers, body )
|
|
231
|
-
request
|
|
232
|
-
|
|
235
|
+
def mole_info( env, elapsed, status, headers, body )
|
|
236
|
+
request = Rack::Request.new( env )
|
|
237
|
+
response = nil
|
|
238
|
+
begin
|
|
239
|
+
response = Rack::Response.new( body, status, headers )
|
|
240
|
+
rescue
|
|
241
|
+
;
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
info = OrderedHash.new
|
|
233
245
|
|
|
234
246
|
return info unless mole_request?( request )
|
|
235
|
-
|
|
247
|
+
|
|
236
248
|
session = env['rack.session']
|
|
237
249
|
route = get_route( request )
|
|
238
250
|
|
|
@@ -257,29 +269,32 @@ module Rack
|
|
|
257
269
|
info[:type] = (elapsed and elapsed > options[:perf_threshold] ? Rackamole.perf : Rackamole.feature)
|
|
258
270
|
info[:app_name] = options[:app_name]
|
|
259
271
|
info[:environment] = options[:environment] || "Unknown"
|
|
260
|
-
info[:user_id] = user_id
|
|
272
|
+
info[:user_id] = user_id if user_id
|
|
261
273
|
info[:user_name] = user_name || "Unknown"
|
|
262
|
-
info[:ip] = ip
|
|
263
|
-
info[:browser] = id_browser( user_agent )
|
|
264
274
|
info[:host] = env['SERVER_NAME']
|
|
265
|
-
info[:software] = env['SERVER_SOFTWARE']
|
|
266
275
|
info[:request_time] = elapsed if elapsed
|
|
267
|
-
info[:url] = request.url
|
|
268
276
|
info[:method] = env['REQUEST_METHOD']
|
|
269
|
-
info[:
|
|
270
|
-
info[:route_info] = route if route
|
|
277
|
+
info[:route_info] = route if route
|
|
271
278
|
info[:created_at] = Time.now.utc
|
|
279
|
+
|
|
280
|
+
# Optional elements...
|
|
281
|
+
mole?( :software , info, env['SERVER_SOFTWARE'] )
|
|
282
|
+
mole?( :ip , info, ip )
|
|
283
|
+
mole?( :browser , info, id_browser( user_agent ) )
|
|
284
|
+
mole?( :url , info, request.url )
|
|
285
|
+
mole?( :path , info, request.path )
|
|
286
|
+
mole?( :status , info, status )
|
|
287
|
+
mole?( :headers , info, headers )
|
|
288
|
+
mole?( :body , info, response.body ) if response
|
|
272
289
|
|
|
273
290
|
# Dump request params
|
|
274
291
|
unless request.params.empty?
|
|
275
292
|
info[:params] = filter_params( request.params, options[:param_excludes] || [] )
|
|
276
|
-
# request.params.keys.sort.each { |k| info[:params][k.to_sym] = request.params[k].to_json }
|
|
277
293
|
end
|
|
278
294
|
|
|
279
295
|
# Dump session var
|
|
280
296
|
if session and !session.empty?
|
|
281
297
|
info[:session] = filter_params( session, options[:session_excludes] || [] )
|
|
282
|
-
# session.keys.sort{ |a,b| a.to_s <=> b.to_s }.each { |k| info[:session][k.to_sym] = session[k].to_json }
|
|
283
298
|
end
|
|
284
299
|
|
|
285
300
|
# Check if an exception was raised. If so consume it and clear state
|
|
@@ -293,7 +308,14 @@ module Rack
|
|
|
293
308
|
end
|
|
294
309
|
info
|
|
295
310
|
end
|
|
296
|
-
|
|
311
|
+
|
|
312
|
+
# check exclusion to see if the information should be moled
|
|
313
|
+
def mole?( key, stash, value )
|
|
314
|
+
# puts "Checking #{key} -- #{options[:mole_excludes].inspect}"
|
|
315
|
+
return stash[key] = value if !options[:mole_excludes] or options[:mole_excludes].empty?
|
|
316
|
+
stash[key] = (options[:mole_excludes].include?( key ) ? nil : value)
|
|
317
|
+
end
|
|
318
|
+
|
|
297
319
|
# filters out params hash and convert values to json
|
|
298
320
|
def filter_params( source, excludes )
|
|
299
321
|
results = OrderedHash.new
|
|
@@ -98,8 +98,7 @@ module Rackamole
|
|
|
98
98
|
def default_options
|
|
99
99
|
{
|
|
100
100
|
:host => 'localhost',
|
|
101
|
-
:port => Mongo::Connection::DEFAULT_PORT
|
|
102
|
-
:db_name => 'mole_mdb'
|
|
101
|
+
:port => Mongo::Connection::DEFAULT_PORT
|
|
103
102
|
}
|
|
104
103
|
end
|
|
105
104
|
|
|
@@ -210,7 +209,10 @@ module Rackamole
|
|
|
210
209
|
:ruby_version => :ver,
|
|
211
210
|
:fault => :msg,
|
|
212
211
|
:stack => :sta,
|
|
213
|
-
:created_at => :cro
|
|
212
|
+
:created_at => :cro,
|
|
213
|
+
:status => :sts,
|
|
214
|
+
:headers => :hdr,
|
|
215
|
+
:body => :bod
|
|
214
216
|
}
|
|
215
217
|
end
|
|
216
218
|
end
|
|
@@ -3,7 +3,7 @@ require 'chronic'
|
|
|
3
3
|
|
|
4
4
|
describe Rackamole::Alert::Twitt do
|
|
5
5
|
before( :each ) do
|
|
6
|
-
@alert = Rackamole::Alert::Twitt.new( 'fernand', "blee" )
|
|
6
|
+
@alert = Rackamole::Alert::Twitt.new( nil, 'fernand', "blee" )
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "should truncate a message correctly" do
|
|
@@ -35,11 +35,11 @@ describe Rackamole::Alert::Twitt do
|
|
|
35
35
|
twitt = mock( Rackamole::Alert::Twitt )
|
|
36
36
|
client = Twitter::Client.stub!( :new )
|
|
37
37
|
|
|
38
|
-
Rackamole::Alert::Twitt.should_receive( :new ).with( 'blee', 'duh').once.and_return( twitt )
|
|
38
|
+
Rackamole::Alert::Twitt.should_receive( :new ).with( nil, 'blee', 'duh').once.and_return( twitt )
|
|
39
39
|
# client.should_receive( :new ).once.and_return( client )
|
|
40
40
|
twitt.should_receive( :send_alert ).with( @args ).once.and_return( "yeah" )
|
|
41
41
|
|
|
42
|
-
Rackamole::Alert::Twitt.deliver_alert( "blee", "duh", @args )
|
|
42
|
+
Rackamole::Alert::Twitt.deliver_alert( nil, "blee", "duh", @args )
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should twitt a feature alert correctly" do
|
data/spec/rackamole/mole_spec.rb
CHANGED
|
@@ -161,7 +161,39 @@ describe Rack::Mole do
|
|
|
161
161
|
fault.count.should == 1
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
|
+
|
|
165
|
+
# ---------------------------------------------------------------------------
|
|
166
|
+
describe "exclusions" do
|
|
167
|
+
before( :each) do
|
|
168
|
+
opts = @opts.clone
|
|
169
|
+
opts[:mole_excludes] = [:headers, :body, :browser, :ip, :url]
|
|
170
|
+
app( opts )
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should exclude some mole attributes correctly" do
|
|
174
|
+
get "/fred/blee", nil, @test_env
|
|
164
175
|
|
|
176
|
+
@test_store.mole_result[:app_name].should == "Test App"
|
|
177
|
+
@test_store.mole_result[:environment].should == :test
|
|
178
|
+
@test_store.mole_result[:user_id].should be_nil
|
|
179
|
+
@test_store.mole_result[:user_name].should == 'fernand'
|
|
180
|
+
@test_store.mole_result[:method].should == 'GET'
|
|
181
|
+
@test_store.mole_result[:path].should == '/fred/blee'
|
|
182
|
+
@test_store.mole_result[:type].should == Rackamole.feature
|
|
183
|
+
@test_store.mole_result[:params].should be_nil
|
|
184
|
+
@test_store.mole_result[:session].should_not be_nil
|
|
185
|
+
@test_store.mole_result[:session].keys.should have(2).items
|
|
186
|
+
@test_store.mole_result[:status].should == 200
|
|
187
|
+
|
|
188
|
+
# Excluded
|
|
189
|
+
@test_store.mole_result[:headers].should be_nil
|
|
190
|
+
@test_store.mole_result[:body].should be_nil
|
|
191
|
+
@test_store.mole_result[:browser].should be_nil
|
|
192
|
+
@test_store.mole_result[:ip].should be_nil
|
|
193
|
+
@test_store.mole_result[:url].should be_nil
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
165
197
|
# ---------------------------------------------------------------------------
|
|
166
198
|
describe 'moling a request' do
|
|
167
199
|
before :each do
|
|
@@ -170,6 +202,7 @@ describe Rack::Mole do
|
|
|
170
202
|
|
|
171
203
|
it "should set the mole meta correctly" do
|
|
172
204
|
get "/fred/blee", nil, @test_env
|
|
205
|
+
|
|
173
206
|
@test_store.mole_result[:app_name].should == "Test App"
|
|
174
207
|
@test_store.mole_result[:environment].should == :test
|
|
175
208
|
@test_store.mole_result[:user_id].should be_nil
|
|
@@ -183,6 +216,9 @@ describe Rack::Mole do
|
|
|
183
216
|
@test_store.mole_result[:params].should be_nil
|
|
184
217
|
@test_store.mole_result[:session].should_not be_nil
|
|
185
218
|
@test_store.mole_result[:session].keys.should have(2).items
|
|
219
|
+
@test_store.mole_result[:status].should == 200
|
|
220
|
+
@test_store.mole_result[:headers].should == { "Content-Type" => "text/plain" }
|
|
221
|
+
@test_store.mole_result[:body].should be_nil
|
|
186
222
|
end
|
|
187
223
|
|
|
188
224
|
it "mole an exception correctly" do
|
|
@@ -195,7 +231,7 @@ describe Rack::Mole do
|
|
|
195
231
|
@test_store.mole_result[:stack].should have(4).items
|
|
196
232
|
@test_store.mole_result[:fault].should == 'Oh snap!'
|
|
197
233
|
last_request.env['mole.stash'].should_not be_nil
|
|
198
|
-
fault = last_request.env['mole.stash'].send( :find_fault, "/", "./spec/rackamole/mole_spec.rb:
|
|
234
|
+
fault = last_request.env['mole.stash'].send( :find_fault, "/", "./spec/rackamole/mole_spec.rb:226" )
|
|
199
235
|
fault.should_not be_nil
|
|
200
236
|
fault.count.should == 1
|
|
201
237
|
end
|
|
@@ -234,7 +270,7 @@ describe Rack::Mole do
|
|
|
234
270
|
it "should find route info correctly" do
|
|
235
271
|
RAILS_ENV = true
|
|
236
272
|
ActionController::Routing::Routes.stub!( :recognize_path ).and_return( { :controller => 'fred', :action => 'blee' } )
|
|
237
|
-
rack = Rack::Mole.new( nil )
|
|
273
|
+
rack = Rack::Mole.new( nil, :app_name => "test app" )
|
|
238
274
|
|
|
239
275
|
# routes.should_receive( 'recognize_path' ).with( 'fred', { :method => 'blee' } ).and_return( )
|
|
240
276
|
res = rack.send( :get_route, OpenStruct.new( :path => "/", :request_method => "GET") )
|
|
@@ -288,12 +324,13 @@ describe Rack::Mole do
|
|
|
288
324
|
describe '#alertable?' do
|
|
289
325
|
before( :each ) do
|
|
290
326
|
@rack = Rack::Mole.new( nil,
|
|
291
|
-
:
|
|
327
|
+
:app_name => "test app",
|
|
328
|
+
:twitter => {
|
|
292
329
|
:username => 'fred',
|
|
293
330
|
:password => 'blee',
|
|
294
331
|
:alert_on => [Rackamole.perf, Rackamole.fault]
|
|
295
332
|
},
|
|
296
|
-
:email
|
|
333
|
+
:email => {
|
|
297
334
|
:from => 'fred',
|
|
298
335
|
:to => ['blee'],
|
|
299
336
|
:alert_on => [Rackamole.perf, Rackamole.fault, Rackamole.feature]
|
|
@@ -321,6 +358,7 @@ describe Rack::Mole do
|
|
|
321
358
|
describe '#configured?' do
|
|
322
359
|
before( :each ) do
|
|
323
360
|
options = {
|
|
361
|
+
:app_name => "test app",
|
|
324
362
|
:blee => [1,2,3],
|
|
325
363
|
:twitter => { :username => 'Fernand', :password => "Blee", :alert_on => [Rackamole.perf, Rackamole.fault] },
|
|
326
364
|
}
|
|
@@ -354,7 +392,7 @@ describe Rack::Mole do
|
|
|
354
392
|
# ---------------------------------------------------------------------------
|
|
355
393
|
describe '#id_browser' do
|
|
356
394
|
before :all do
|
|
357
|
-
@rack = Rack::Mole.new( nil )
|
|
395
|
+
@rack = Rack::Mole.new( nil, :app_name => "test app" )
|
|
358
396
|
end
|
|
359
397
|
|
|
360
398
|
it "should detect a browser type correctly" do
|
|
@@ -442,4 +480,13 @@ describe Rack::Mole do
|
|
|
442
480
|
|
|
443
481
|
end
|
|
444
482
|
|
|
483
|
+
# ---------------------------------------------------------------------------
|
|
484
|
+
describe 'required params' do
|
|
485
|
+
it "should crap out if a required param is omitted" do
|
|
486
|
+
lambda {
|
|
487
|
+
Rack::Mole.new( app )
|
|
488
|
+
}.should raise_error( /app_name/ )
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
|
|
445
492
|
end
|
|
@@ -9,7 +9,7 @@ describe Rackamole::Store::MongoDb do
|
|
|
9
9
|
@store = Rackamole::Store::MongoDb.new(
|
|
10
10
|
:host => 'localhost',
|
|
11
11
|
:port => 27017,
|
|
12
|
-
:
|
|
12
|
+
:db_name => 'mole_app_test_mdb',
|
|
13
13
|
:logger => Rackamole::Logger.new( :file_name => $stdout, :log_level => 'info' ) )
|
|
14
14
|
@db = @store.database
|
|
15
15
|
end
|
|
@@ -19,7 +19,7 @@ describe Rackamole::Store::MongoDb do
|
|
|
19
19
|
|
|
20
20
|
@args = OrderedHash.new
|
|
21
21
|
@args[:type] = Rackamole.feature
|
|
22
|
-
@args[:app_name] = "
|
|
22
|
+
@args[:app_name] = "app"
|
|
23
23
|
@args[:environment] = :test
|
|
24
24
|
@args[:perf_issue] = false
|
|
25
25
|
@args[:ip] = "1.1.1.1"
|
|
@@ -42,7 +42,7 @@ describe Rackamole::Store::MongoDb do
|
|
|
42
42
|
|
|
43
43
|
feature = @store.features.find_one()
|
|
44
44
|
feature.should_not be_nil
|
|
45
|
-
feature['app'].should == '
|
|
45
|
+
feature['app'].should == 'app'
|
|
46
46
|
feature['env'].should == 'test'
|
|
47
47
|
feature['ctx'].should == '/fred'
|
|
48
48
|
|
|
@@ -63,7 +63,7 @@ describe Rackamole::Store::MongoDb do
|
|
|
63
63
|
|
|
64
64
|
feature = @store.features.find_one( log['fid'] )
|
|
65
65
|
feature.should_not be_nil
|
|
66
|
-
feature['app'].should == '
|
|
66
|
+
feature['app'].should == 'app'
|
|
67
67
|
feature['env'].should == 'test'
|
|
68
68
|
feature['ctx'].should == '/fred'
|
|
69
69
|
feature['did'].should == '20091127'
|