mole 1.0.12 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- metadata +24 -146
- data/History.txt +0 -17
- data/Manifest.txt +0 -132
- data/README.txt +0 -216
- data/Rakefile +0 -46
- data/config/database.yml +0 -21
- data/config/test_database.yml +0 -69
- data/lib/mole.rb +0 -260
- data/lib/mole/db/migrate.rb +0 -90
- data/lib/mole/e_mole.rb +0 -75
- data/lib/mole/logger.rb +0 -134
- data/lib/mole/models/mole_feature.rb +0 -58
- data/lib/mole/models/mole_log.rb +0 -31
- data/lib/mole/module.rb +0 -292
- data/lib/mole/moler.rb +0 -71
- data/lib/mole/utils/frameworks.rb +0 -53
- data/lib/mole/version.rb +0 -15
- data/samples/merbapp/README +0 -14
- data/samples/merbapp/Rakefile +0 -124
- data/samples/merbapp/app/controllers/application.rb +0 -3
- data/samples/merbapp/app/controllers/exceptions.rb +0 -13
- data/samples/merbapp/app/controllers/moled.rb +0 -25
- data/samples/merbapp/app/helpers/global_helper.rb +0 -5
- data/samples/merbapp/app/mailers/views/layout/application.html.erb +0 -1
- data/samples/merbapp/app/mailers/views/layout/application.text.erb +0 -1
- data/samples/merbapp/app/parts/views/layout/application.html.erb +0 -1
- data/samples/merbapp/app/views/exceptions/internal_server_error.html.erb +0 -216
- data/samples/merbapp/app/views/exceptions/not_acceptable.html.erb +0 -38
- data/samples/merbapp/app/views/exceptions/not_found.html.erb +0 -40
- data/samples/merbapp/app/views/layout/application.html.erb +0 -11
- data/samples/merbapp/app/views/moled/index.html.erb +0 -5
- data/samples/merbapp/app/views/moled/result.html.erb +0 -5
- data/samples/merbapp/config/boot.rb +0 -11
- data/samples/merbapp/config/dependencies.rb +0 -41
- data/samples/merbapp/config/environments/development.rb +0 -1
- data/samples/merbapp/config/environments/production.rb +0 -1
- data/samples/merbapp/config/environments/test.rb +0 -1
- data/samples/merbapp/config/merb.yml +0 -82
- data/samples/merbapp/config/merb_init.rb +0 -26
- data/samples/merbapp/config/mole_config.rb +0 -33
- data/samples/merbapp/config/router.rb +0 -38
- data/samples/merbapp/config/upload.conf +0 -0
- data/samples/merbapp/public/images/merb.jpg +0 -0
- data/samples/merbapp/public/merb.fcgi +0 -6
- data/samples/merbapp/public/stylesheets/master.css +0 -119
- data/samples/merbapp/script/destroy +0 -32
- data/samples/merbapp/script/generate +0 -32
- data/samples/merbapp/script/stop_merb +0 -13
- data/samples/merbapp/spec/spec_helper.rb +0 -15
- data/samples/merbapp/test/test_helper.rb +0 -14
- data/samples/railsapp/README +0 -14
- data/samples/railsapp/Rakefile +0 -10
- data/samples/railsapp/app/controllers/application.rb +0 -13
- data/samples/railsapp/app/controllers/moled_controller.rb +0 -23
- data/samples/railsapp/app/helpers/application_helper.rb +0 -3
- data/samples/railsapp/app/views/moled/index.html.erb +0 -5
- data/samples/railsapp/app/views/moled/result.html.erb +0 -5
- data/samples/railsapp/config/boot.rb +0 -109
- data/samples/railsapp/config/database.yml +0 -13
- data/samples/railsapp/config/environment.rb +0 -59
- data/samples/railsapp/config/environments/development.rb +0 -18
- data/samples/railsapp/config/environments/production.rb +0 -20
- data/samples/railsapp/config/environments/test.rb +0 -22
- data/samples/railsapp/config/initializers/inflections.rb +0 -10
- data/samples/railsapp/config/initializers/mime_types.rb +0 -5
- data/samples/railsapp/config/initializers/mole.rb +0 -10
- data/samples/railsapp/config/moles/mole_config.rb +0 -44
- data/samples/railsapp/config/routes.rb +0 -35
- data/samples/railsapp/doc/README_FOR_APP +0 -2
- data/samples/railsapp/public/.htaccess +0 -40
- data/samples/railsapp/public/404.html +0 -30
- data/samples/railsapp/public/422.html +0 -30
- data/samples/railsapp/public/500.html +0 -30
- data/samples/railsapp/public/dispatch.cgi +0 -10
- data/samples/railsapp/public/dispatch.fcgi +0 -24
- data/samples/railsapp/public/dispatch.rb +0 -10
- data/samples/railsapp/public/favicon.ico +0 -0
- data/samples/railsapp/public/images/rails.png +0 -0
- data/samples/railsapp/public/javascripts/application.js +0 -2
- data/samples/railsapp/public/javascripts/controls.js +0 -963
- data/samples/railsapp/public/javascripts/dragdrop.js +0 -972
- data/samples/railsapp/public/javascripts/effects.js +0 -1120
- data/samples/railsapp/public/javascripts/prototype.js +0 -4225
- data/samples/railsapp/public/robots.txt +0 -5
- data/samples/railsapp/script/about +0 -3
- data/samples/railsapp/script/console +0 -3
- data/samples/railsapp/script/destroy +0 -3
- data/samples/railsapp/script/generate +0 -3
- data/samples/railsapp/script/performance/benchmarker +0 -3
- data/samples/railsapp/script/performance/profiler +0 -3
- data/samples/railsapp/script/performance/request +0 -3
- data/samples/railsapp/script/plugin +0 -3
- data/samples/railsapp/script/process/inspector +0 -3
- data/samples/railsapp/script/process/reaper +0 -3
- data/samples/railsapp/script/process/spawner +0 -3
- data/samples/railsapp/script/runner +0 -3
- data/samples/railsapp/script/server +0 -3
- data/samples/railsapp/test/test_helper.rb +0 -38
- data/samples/rubyapp/README +0 -22
- data/samples/rubyapp/bin/ruby_app +0 -35
- data/samples/rubyapp/config/mole_conf.rb +0 -31
- data/samples/rubyapp/lib/fred.rb +0 -22
- data/spec/config/auto_mole_config.rb +0 -26
- data/spec/config/mole_config.rb +0 -0
- data/spec/config/moles/fred_config.rb +0 -0
- data/spec/data/blee.rb +0 -64
- data/spec/db/migrate_spec.rb +0 -19
- data/spec/emole_spec.rb +0 -43
- data/spec/logger_spec.rb +0 -56
- data/spec/models/mole_feature_spec.rb +0 -48
- data/spec/models/mole_log_spec.rb +0 -62
- data/spec/module_spec.rb +0 -229
- data/spec/mole_spec.rb +0 -135
- data/spec/moler_spec.rb +0 -77
- data/spec/spec_helper.rb +0 -76
- data/spec/utils/framework_spec.rb +0 -99
- data/tasks/ann.rake +0 -76
- data/tasks/annotations.rake +0 -22
- data/tasks/doc.rake +0 -48
- data/tasks/gem.rake +0 -110
- data/tasks/manifest.rake +0 -49
- data/tasks/mole.rake +0 -115
- data/tasks/post_load.rake +0 -26
- data/tasks/rubyforge.rake +0 -57
- data/tasks/setup.rb +0 -227
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -44
- data/tasks/test.rake +0 -38
- data/templates/mole/e_mole/exception_alerts.rhtml +0 -14
- data/templates/mole/e_mole/feature_alerts.rhtml +0 -11
- data/templates/mole/e_mole/perf_alerts.rhtml +0 -12
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "spec_helper" )
|
2
|
-
|
3
|
-
describe MoleFeature do
|
4
|
-
before( :each ) do
|
5
|
-
::Mole.reset_configuration!
|
6
|
-
::Mole.initialize( :application => "Test",
|
7
|
-
:mode => :persistent,
|
8
|
-
:log_level => :debug,
|
9
|
-
:moleable => true )
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should find or create known features correctly" do
|
13
|
-
%w[ all performance exception].each do |f|
|
14
|
-
feature = MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
|
15
|
-
feature.should_not be_nil
|
16
|
-
feature.name.downcase.should == f
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should create a new feature" do
|
21
|
-
feature = MoleFeature.find_or_create_feature( "Fred", ::Mole.application, self.class.name )
|
22
|
-
feature.should_not be_nil
|
23
|
-
feature.name.should == "Fred"
|
24
|
-
feature.context.should == self.class.name
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should not create a feature with no name" do
|
28
|
-
feature = MoleFeature.find_or_create_feature( "", ::Mole.application, self.class.name )
|
29
|
-
feature.should be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should find all features for a given application correctly" do
|
33
|
-
%w[ all performance exception].each do |f|
|
34
|
-
MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
|
35
|
-
end
|
36
|
-
MoleFeature.find_or_create_feature( "Fred", ::Mole.application, self.class.name )
|
37
|
-
features = MoleFeature.find_features( ::Mole.application )
|
38
|
-
features.should have(4).mole_features
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should find moled application names correctly" do
|
42
|
-
MoleFeature.find_moled_application_names.should be_empty
|
43
|
-
%w[ all performance exception].each do |f|
|
44
|
-
feature = MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
|
45
|
-
end
|
46
|
-
MoleFeature.find_moled_application_names.should == ["Test"]
|
47
|
-
end
|
48
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "spec_helper" )
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
describe MoleLog do
|
5
|
-
before( :each ) do
|
6
|
-
::Mole.reset_configuration!
|
7
|
-
::Mole.initialize( :mode => :persistent, :log_level => :info, :moleable => true )
|
8
|
-
@args = { :blee => "Hello", :duh => "World" }
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should log unchecked exceptions correctly" do
|
12
|
-
args = @args
|
13
|
-
feature = MoleFeature.find_exception_feature( ::Mole.application )
|
14
|
-
feature.should_not be_nil
|
15
|
-
begin
|
16
|
-
raise "Something crapped out"
|
17
|
-
rescue => boom
|
18
|
-
args[:boom] = Mole::Moler.dump_stack( boom )
|
19
|
-
MoleLog.log_it( self, feature, 100, args )
|
20
|
-
end
|
21
|
-
check_it( feature, 100, @args )
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should log perf exception correctly" do
|
25
|
-
feature = MoleFeature.find_performance_feature( ::Mole.application )
|
26
|
-
feature.should_not be_nil
|
27
|
-
MoleLog.log_it( self, feature, 200, @args )
|
28
|
-
check_it( feature, 200, @args )
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should mole a feature correctly" do
|
32
|
-
feature = MoleFeature.find_or_create_feature( "fred", ::Mole.application, "Test".class.name )
|
33
|
-
feature.should_not be_nil
|
34
|
-
MoleLog.log_it( "Test", feature, 300, @args )
|
35
|
-
check_it( feature, 300, @args )
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should log request info correctly" do
|
39
|
-
ctrl = Moled::Controller.new
|
40
|
-
feature = MoleFeature.find_or_create_feature( "fred", ::Mole.application, ctrl.class.name )
|
41
|
-
feature.should_not be_nil
|
42
|
-
MoleLog.log_it( ctrl, feature, 400, @args )
|
43
|
-
log = check_it( feature, 400, @args )
|
44
|
-
log.ip_address.should == "1.1.1.1"
|
45
|
-
log.browser_type.should == "GodZilla"
|
46
|
-
end
|
47
|
-
|
48
|
-
# Test Controller...
|
49
|
-
module Moled
|
50
|
-
class Controller
|
51
|
-
class Request
|
52
|
-
def env
|
53
|
-
{'REMOTE_ADDR' => "1.1.1.1", 'HTTP_USER_AGENT' => 'GodZilla' }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def request
|
58
|
-
Request.new
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/spec/module_spec.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper" )
|
2
|
-
|
3
|
-
|
4
|
-
describe Module do
|
5
|
-
before( :all ) do
|
6
|
-
::Mole.initialize( :perf_threshold => 1, :log_level => :info )
|
7
|
-
require File.join( File.dirname(__FILE__), %w[data blee] )
|
8
|
-
end
|
9
|
-
|
10
|
-
before( :each ) do
|
11
|
-
@blee = Blee.new
|
12
|
-
CallStackChecker.reset!
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should handle features with punctuation correctly" do
|
16
|
-
Blee.mole_before( :feature => :get_out? ) { |context, feature, *args|
|
17
|
-
CallStackChecker.called
|
18
|
-
}
|
19
|
-
@blee.get_out?
|
20
|
-
CallStackChecker.should be_called
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should trap mole before handler exceptions" do
|
24
|
-
Blee.mole_before( :feature => :crap_out ) { |context, feature, *args|
|
25
|
-
raise "LEGIT !! - Before - Something did crap out"
|
26
|
-
CallStackChecker.called
|
27
|
-
}
|
28
|
-
@blee.crap_out
|
29
|
-
CallStackChecker.should_not be_called
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should trap mole after handler exceptions" do
|
33
|
-
Blee.mole_after( :feature => :crap_out ) { |context, feature, *args|
|
34
|
-
raise "LEGIT !! - After - Something did crap out"
|
35
|
-
CallStackChecker.called
|
36
|
-
}
|
37
|
-
@blee.crap_out
|
38
|
-
CallStackChecker.should_not be_called
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should trap mole handler exceptions" do
|
42
|
-
Blee.mole_unchecked( :features => [:blee_raise_too] ) { |context, feature, *args|
|
43
|
-
raise "-- LEGIT !! - Unchecked - Something did crap out"
|
44
|
-
CallStackChecker.called
|
45
|
-
}
|
46
|
-
@blee.blee_raise_too rescue nil
|
47
|
-
CallStackChecker.should_not be_called
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should trap a perf handler exception" do
|
51
|
-
Blee.mole_perf( :features => [:blee_slow_too] ) do |context, feature, elapsed_time, args, block|
|
52
|
-
raise "---LEGIT !! - Perf - Something did crap out"
|
53
|
-
CallStackChecker.called
|
54
|
-
end
|
55
|
-
@blee.blee_slow_too
|
56
|
-
CallStackChecker.should_not be_called
|
57
|
-
end
|
58
|
-
|
59
|
-
# it "should trap mole handler exceptions" do
|
60
|
-
# Blee.mole_before( :feature => :crap_out ) { |context, feature, *args|
|
61
|
-
# raise "Something did crap out"
|
62
|
-
# CallStackChecker.called
|
63
|
-
# }
|
64
|
-
# @blee.crap_out
|
65
|
-
# CallStackChecker.should_not be_called
|
66
|
-
# end
|
67
|
-
|
68
|
-
it "should correctly setup a before call" do
|
69
|
-
Blee.mole_before( :feature => :blee_no_args ) { |context, feature, block, *args|
|
70
|
-
context.class.should == Blee
|
71
|
-
feature.should == "blee_no_args"
|
72
|
-
block.should be_nil
|
73
|
-
args.should have(0).items
|
74
|
-
CallStackChecker.called
|
75
|
-
}
|
76
|
-
@blee.blee_no_args
|
77
|
-
CallStackChecker.should be_called
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should correctly setup an after call" do
|
81
|
-
Blee.mole_after( :feature => :blee_no_args ) { |context, feature, ret_val, block, *args|
|
82
|
-
context.class.should == Blee
|
83
|
-
feature.should == "blee_no_args"
|
84
|
-
args.should have(0).items
|
85
|
-
CallStackChecker.called
|
86
|
-
}
|
87
|
-
@blee.blee_no_args
|
88
|
-
CallStackChecker.should be_called
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should correctly trap an exception" do
|
92
|
-
Blee.mole_unchecked( :features => [:blee_raise] ) do |context, feature, boom, args, block|
|
93
|
-
context.class.should == Blee
|
94
|
-
feature.should == "blee_raise"
|
95
|
-
boom.to_s.should == "Blee exception"
|
96
|
-
CallStackChecker.called
|
97
|
-
end
|
98
|
-
@blee.blee_raise rescue nil
|
99
|
-
CallStackChecker.should be_called
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should not trap a before call" do
|
103
|
-
@blee.blee_args( "Hello", "World", "Good", "Day" )
|
104
|
-
CallStackChecker.should_not be_called
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should correctly trap the before call arguments" do
|
108
|
-
Blee.mole_before( :feature => :blee_args ) { |context, feature, block, *args|
|
109
|
-
context.class.should == Blee
|
110
|
-
feature.should == "blee_args"
|
111
|
-
args.should have(4).items
|
112
|
-
args[0].should == "Hello"
|
113
|
-
args[1].should == "World"
|
114
|
-
args[2].should == "Good"
|
115
|
-
args[3].should == "Day"
|
116
|
-
CallStackChecker.called
|
117
|
-
}
|
118
|
-
@blee.blee_args( "Hello", "World", "Good", "Day" )
|
119
|
-
CallStackChecker.should be_called
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should correctly trap a before call with a block" do
|
123
|
-
Blee.mole_before( :feature => :blee_block ) do |context, feature, block, *args|
|
124
|
-
context.class.should == Blee
|
125
|
-
feature.should == "blee_block"
|
126
|
-
block.should_not be_nil
|
127
|
-
block.call.should == "Do it already!!"
|
128
|
-
args.size.should == 4
|
129
|
-
args[0].should == "Hello"
|
130
|
-
args[1].should == "World"
|
131
|
-
args[2].should == "Good"
|
132
|
-
args[3].should == "Day"
|
133
|
-
CallStackChecker.called
|
134
|
-
end
|
135
|
-
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
136
|
-
CallStackChecker.should be_called
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should correctly trap the after call with many arguments" do
|
140
|
-
Blee.mole_after( :feature => :blee_args ) { |context, feature, ret_val, block, *args|
|
141
|
-
context.class.should == Blee
|
142
|
-
feature.should == "blee_args"
|
143
|
-
ret_val.should == 20
|
144
|
-
args.size.should == 4
|
145
|
-
args[0].should == "Hello"
|
146
|
-
args[1].should == "World"
|
147
|
-
args[2].should == "Good"
|
148
|
-
args[3].should == "Day"
|
149
|
-
CallStackChecker.called
|
150
|
-
}
|
151
|
-
@blee.blee_args( "Hello", "World", "Good", "Day" )
|
152
|
-
CallStackChecker.should be_called
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should correctly trap the after call with a block" do
|
156
|
-
Blee.mole_after( :feature => :blee_block ) do |context, feature, ret_val, block, *args|
|
157
|
-
context.class.should == Blee
|
158
|
-
feature.should == "blee_block"
|
159
|
-
block.should_not be_nil
|
160
|
-
block.call.should == "Do it already!!"
|
161
|
-
ret_val.should == 10
|
162
|
-
args.size.should == 4
|
163
|
-
args[0].should == "Hello"
|
164
|
-
args[1].should == "World"
|
165
|
-
args[2].should == "Good"
|
166
|
-
args[3].should == "Day"
|
167
|
-
CallStackChecker.called
|
168
|
-
end
|
169
|
-
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
170
|
-
CallStackChecker.should be_called
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should correctly trap a slow call" do
|
174
|
-
Blee.mole_perf( :features => [:blee_slow] ) do |context, feature, elapsed_time, ret_val, block, *args|
|
175
|
-
context.class.should == Blee
|
176
|
-
feature.should == "blee_slow"
|
177
|
-
ret_val.should == 1
|
178
|
-
block.should be_nil
|
179
|
-
args.size.should == 0
|
180
|
-
elapsed_time.should > 1
|
181
|
-
CallStackChecker.called
|
182
|
-
end
|
183
|
-
@blee.blee_slow
|
184
|
-
CallStackChecker.should be_called
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should trap a private method correctly" do
|
188
|
-
Blee.mole_after( :feature => :blee_private ) { |context, feature, ret_val, block, *args|
|
189
|
-
context.class.should == Blee
|
190
|
-
feature.should == "blee_private"
|
191
|
-
ret_val.should == "Hello"
|
192
|
-
block.should be_nil
|
193
|
-
args.size.should == 1
|
194
|
-
args[0].should == "Hello"
|
195
|
-
CallStackChecker.called
|
196
|
-
}
|
197
|
-
@blee.send( :blee_private, "Hello" )
|
198
|
-
CallStackChecker.should be_called
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should trap a protected method correctly" do
|
202
|
-
Blee.mole_after( :feature => :blee_protected ) { |context, feature, ret_val, block, *args|
|
203
|
-
context.class.should == Blee
|
204
|
-
feature.should == "blee_protected"
|
205
|
-
ret_val.should == "Hello"
|
206
|
-
block.should be_nil
|
207
|
-
args.size.should == 1
|
208
|
-
args[0].should == "Hello"
|
209
|
-
CallStackChecker.called
|
210
|
-
}
|
211
|
-
@blee.send( :blee_protected, "Hello" )
|
212
|
-
CallStackChecker.should be_called
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should mole a static method correctly" do
|
216
|
-
pending do
|
217
|
-
Blee.mole_after( :feature => :blee_static ) { |context, feature, ret_val, block, *args|
|
218
|
-
context.class.should == Blee
|
219
|
-
feature.should == "blee_static"
|
220
|
-
ret_val.should be_nil
|
221
|
-
block.should be_nil
|
222
|
-
args.size.should == 0
|
223
|
-
CallStackChecker.called
|
224
|
-
}
|
225
|
-
Blee.blee_static
|
226
|
-
CallStackChecker.should be_called
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
data/spec/mole_spec.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper" )
|
2
|
-
|
3
|
-
describe Mole do
|
4
|
-
before( :all ) do
|
5
|
-
::Mole.reset_configuration!
|
6
|
-
::Mole.initialize( :moleable => true )
|
7
|
-
@root = ::File.expand_path( ::File.join(::File.dirname(__FILE__), ".." ) )
|
8
|
-
end
|
9
|
-
|
10
|
-
it "is versioned" do
|
11
|
-
::Mole::Version.version.should =~ /\d+\.\d+\.\d+/
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should have the right defaults" do
|
15
|
-
Mole.should be_moleable
|
16
|
-
Mole.logger.should_not be_nil
|
17
|
-
Mole.perf_threshold.should == 5
|
18
|
-
Mole.should_not be_persistent
|
19
|
-
Mole.application.should == "Default"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "generates a correct path relative to root" do
|
23
|
-
Mole.path( "mole.rb" ).should == ::File.join(@root, "mole.rb" )
|
24
|
-
end
|
25
|
-
|
26
|
-
it "generates a correct path relative to lib" do
|
27
|
-
Mole.libpath(%w[ mole db_mole.rb]).should == ::File.join(@root, "lib", "mole", "db_mole.rb")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should define the correct run modes" do
|
31
|
-
Mole.run_modes.should == [:transient,:persistent]
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should dump config info to console" do
|
35
|
-
Mole.dump
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should locate controller classes correctly" do
|
39
|
-
classes = Mole.find_controller_classes( File.join(File.dirname(__FILE__), %w[data] ) )
|
40
|
-
classes.should == %w[Blee]
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ".auto_xxx" do
|
44
|
-
before( :each ) do
|
45
|
-
::Mole.reset_configuration!
|
46
|
-
::Mole.initialize( :perf_threshold => 1, :log_level => :debug )
|
47
|
-
require File.join( File.dirname(__FILE__), %w[data blee] )
|
48
|
-
Blee.send( :mole_clear! )
|
49
|
-
CallStackChecker.reset!
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should auto perf a set of controllers correctly" do
|
53
|
-
Mole.auto_perf( File.join(File.dirname(__FILE__), %w[data] ) ) do |context, feature, elapsed_time, ret_val, block, *args|
|
54
|
-
context.class.should == Blee
|
55
|
-
block.should be_nil
|
56
|
-
args.size.should == 0
|
57
|
-
elapsed_time.should > 1
|
58
|
-
CallStackChecker.called
|
59
|
-
end
|
60
|
-
Blee.new.blee_slow
|
61
|
-
CallStackChecker.should be_called
|
62
|
-
CallStackChecker.reset!
|
63
|
-
Blee.new.blee_slow_too
|
64
|
-
CallStackChecker.should be_called
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should auto check a set of controllers correctly" do
|
68
|
-
Mole.auto_unchecked( File.join(File.dirname(__FILE__), %w[data] ) ) do |context, feature, elapsed_time, block, *args|
|
69
|
-
context.class.should == Blee
|
70
|
-
feature.should == "blee_raise"
|
71
|
-
block.should be_nil
|
72
|
-
args.size.should == 0
|
73
|
-
CallStackChecker.called
|
74
|
-
end
|
75
|
-
Blee.new.blee_raise rescue nil
|
76
|
-
CallStackChecker.should be_called
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should auto before a set of controllers correctly" do
|
80
|
-
Mole.auto_before( File.join(File.dirname(__FILE__), %w[data] ) ) do |context, feature, block, *args|
|
81
|
-
context.class.should == Blee
|
82
|
-
feature.should == "blee_no_args"
|
83
|
-
block.should be_nil
|
84
|
-
args.size.should == 0
|
85
|
-
CallStackChecker.called
|
86
|
-
end
|
87
|
-
Blee.new.blee_no_args
|
88
|
-
CallStackChecker.should be_called
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should auto after a set of controllers correctly" do
|
92
|
-
Mole.auto_after( File.join(File.dirname(__FILE__), %w[data] ) ) do |context, feature, ret_val, block, *args|
|
93
|
-
context.class.should == Blee
|
94
|
-
feature.should == "blee_no_args"
|
95
|
-
ret_val.should == 10
|
96
|
-
block.should be_nil
|
97
|
-
args.size.should == 0
|
98
|
-
CallStackChecker.called
|
99
|
-
end
|
100
|
-
Blee.mole_dump( "After" )
|
101
|
-
Blee.new.blee_no_args
|
102
|
-
CallStackChecker.should be_called
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
describe ".load_mole_configuration" do
|
108
|
-
before( :each ) do
|
109
|
-
::Mole.reset_configuration!
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should load single file correctly" do
|
113
|
-
::Mole.initialize( :moleable => true, :mole_config => File.join( File.dirname(__FILE__), %w[config mole_config.rb] ) )
|
114
|
-
::Mole.load_mole_configuration
|
115
|
-
require( File.join( File.dirname(__FILE__), %w[config mole_config.rb] ) ).should == []
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should load config for directory correctly" do
|
119
|
-
::Mole.initialize( :moleable => true, :mole_config => File.join( File.dirname(__FILE__), %w[config moles] ) )
|
120
|
-
::Mole.load_mole_configuration
|
121
|
-
require( File.join( File.dirname(__FILE__), %w[config moles fred_config.rb] ) ).should == []
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should raise an error if the configuration file does not exist" do
|
125
|
-
::Mole.initialize( :moleable => true, :mole_config => File.join( File.dirname(__FILE__), %w[config fred_mole.rb] ) )
|
126
|
-
lambda{ ::Mole.load_mole_configuration }.should raise_error( "Unable to find the MOle configuration from `./spec/config/fred_mole.rb" )
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should raise an error if the config directory does not exist" do
|
130
|
-
::Mole.initialize( :moleable => true, :mole_config => File.join( File.dirname(__FILE__), %w[config freds] ) )
|
131
|
-
lambda{ ::Mole.load_mole_configuration }.should raise_error( "Unable to find the MOle configuration from `./spec/config/freds" )
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|