mole 1.0.5 → 1.0.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/Manifest.txt +92 -0
- data/README.txt +10 -7
- data/lib/mole.rb +63 -1
- data/lib/mole/module.rb +136 -124
- data/lib/mole/utils/frameworks.rb +32 -7
- data/lib/mole/version.rb +1 -1
- data/notes/notes.txt +1 -0
- data/samples/merbapp/README +14 -0
- data/samples/merbapp/Rakefile +124 -0
- data/samples/merbapp/app/controllers/application.rb +3 -0
- data/samples/merbapp/app/controllers/exceptions.rb +13 -0
- data/samples/merbapp/app/controllers/moled.rb +25 -0
- data/samples/merbapp/app/helpers/global_helper.rb +5 -0
- data/samples/merbapp/app/mailers/views/layout/application.html.erb +1 -0
- data/samples/merbapp/app/mailers/views/layout/application.text.erb +1 -0
- data/samples/merbapp/app/parts/views/layout/application.html.erb +1 -0
- data/samples/merbapp/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/samples/merbapp/app/views/exceptions/not_acceptable.html.erb +38 -0
- data/samples/merbapp/app/views/exceptions/not_found.html.erb +40 -0
- data/samples/merbapp/app/views/layout/application.html.erb +11 -0
- data/samples/merbapp/app/views/moled/index.html.erb +5 -0
- data/samples/merbapp/app/views/moled/result.html.erb +5 -0
- data/samples/merbapp/config/boot.rb +11 -0
- data/samples/merbapp/config/dependencies.rb +41 -0
- data/samples/merbapp/config/environments/development.rb +1 -0
- data/samples/merbapp/config/environments/production.rb +1 -0
- data/samples/merbapp/config/environments/test.rb +1 -0
- data/samples/merbapp/config/merb.yml +82 -0
- data/samples/merbapp/config/merb_init.rb +26 -0
- data/samples/merbapp/config/mole_config.rb +33 -0
- data/samples/merbapp/config/router.rb +38 -0
- data/samples/merbapp/config/upload.conf +0 -0
- data/samples/merbapp/log/merb.4000.pid +1 -0
- data/samples/merbapp/public/images/merb.jpg +0 -0
- data/samples/merbapp/public/merb.fcgi +6 -0
- data/samples/merbapp/public/stylesheets/master.css +119 -0
- data/samples/merbapp/script/destroy +32 -0
- data/samples/merbapp/script/generate +32 -0
- data/samples/merbapp/script/stop_merb +13 -0
- data/samples/merbapp/spec/spec_helper.rb +15 -0
- data/samples/merbapp/test/test_helper.rb +14 -0
- data/samples/railsapp/README +14 -0
- data/samples/railsapp/Rakefile +10 -0
- data/samples/railsapp/app/controllers/application.rb +13 -0
- data/samples/railsapp/app/controllers/moled_controller.rb +23 -0
- data/samples/railsapp/app/helpers/application_helper.rb +3 -0
- data/samples/railsapp/app/views/moled/index.html.erb +5 -0
- data/samples/railsapp/app/views/moled/result.html.erb +5 -0
- data/samples/railsapp/config/boot.rb +109 -0
- data/samples/railsapp/config/database.yml +13 -0
- data/samples/railsapp/config/environment.rb +59 -0
- data/samples/railsapp/config/environments/development.rb +18 -0
- data/samples/railsapp/config/environments/production.rb +20 -0
- data/samples/railsapp/config/environments/test.rb +22 -0
- data/samples/railsapp/config/initializers/inflections.rb +10 -0
- data/samples/railsapp/config/initializers/mime_types.rb +5 -0
- data/samples/railsapp/config/initializers/mole.rb +10 -0
- data/samples/railsapp/config/moles/mole_config.rb +44 -0
- data/samples/railsapp/config/routes.rb +35 -0
- data/samples/railsapp/doc/README_FOR_APP +2 -0
- data/samples/railsapp/log/development.log +3554 -0
- data/samples/railsapp/log/production.log +643 -0
- data/samples/railsapp/log/server.log +0 -0
- data/samples/railsapp/log/test.log +0 -0
- data/samples/railsapp/public/.htaccess +40 -0
- data/samples/railsapp/public/404.html +30 -0
- data/samples/railsapp/public/422.html +30 -0
- data/samples/railsapp/public/500.html +30 -0
- data/samples/railsapp/public/dispatch.cgi +10 -0
- data/samples/railsapp/public/dispatch.fcgi +24 -0
- data/samples/railsapp/public/dispatch.rb +10 -0
- data/samples/railsapp/public/favicon.ico +0 -0
- data/samples/railsapp/public/images/rails.png +0 -0
- data/samples/railsapp/public/javascripts/application.js +2 -0
- data/samples/railsapp/public/javascripts/controls.js +963 -0
- data/samples/railsapp/public/javascripts/dragdrop.js +972 -0
- data/samples/railsapp/public/javascripts/effects.js +1120 -0
- data/samples/railsapp/public/javascripts/prototype.js +4225 -0
- data/samples/railsapp/public/robots.txt +5 -0
- data/samples/railsapp/script/about +3 -0
- data/samples/railsapp/script/console +3 -0
- data/samples/railsapp/script/destroy +3 -0
- data/samples/railsapp/script/generate +3 -0
- data/samples/railsapp/script/performance/benchmarker +3 -0
- data/samples/railsapp/script/performance/profiler +3 -0
- data/samples/railsapp/script/performance/request +3 -0
- data/samples/railsapp/script/plugin +3 -0
- data/samples/railsapp/script/process/inspector +3 -0
- data/samples/railsapp/script/process/reaper +3 -0
- data/samples/railsapp/script/process/spawner +3 -0
- data/samples/railsapp/script/runner +3 -0
- data/samples/railsapp/script/server +3 -0
- data/samples/railsapp/test/test_helper.rb +38 -0
- data/samples/rubyapp/README +22 -0
- data/samples/rubyapp/bin/ruby_app +35 -0
- data/samples/rubyapp/config/mole_conf.rb +31 -0
- data/samples/rubyapp/lib/fred.rb +22 -0
- data/spec/config/auto_mole_config.rb +26 -0
- data/spec/data/blee.rb +1 -1
- data/spec/module_spec.rb +8 -8
- data/spec/mole_spec.rb +70 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/utils/framework_spec.rb +52 -12
- metadata +154 -53
|
@@ -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 Test::Unit::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,22 @@
|
|
|
1
|
+
Sample MOled Ruby App
|
|
2
|
+
|
|
3
|
+
Launch the app using either of the following cmd line
|
|
4
|
+
|
|
5
|
+
> cd samples/rubyapp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
To mole a regular method
|
|
9
|
+
|
|
10
|
+
> ./bin/ruby_app --feature
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
To mole a slow method
|
|
15
|
+
|
|
16
|
+
> ./bin/ruby_app --slow
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
To mole a hosed method that will throw an uncaught exception
|
|
21
|
+
|
|
22
|
+
> ./bin/ruby_app --hosed
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require File.join( File.dirname(__FILE__), %w[.. lib fred] )
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
|
|
5
|
+
# Initializes the MOle. The configuration file will be read from config/mole_conf.rb.
|
|
6
|
+
require 'mole'
|
|
7
|
+
::Mole.initialize( :moleable => true,
|
|
8
|
+
:application => "RubyApp",
|
|
9
|
+
:perf_threshold => 2,
|
|
10
|
+
:mole_config => File.join( File.dirname(__FILE__), %w[.. config mole_conf.rb]) )
|
|
11
|
+
::Mole.dump
|
|
12
|
+
::Mole.load_mole_configuration
|
|
13
|
+
|
|
14
|
+
class Runner
|
|
15
|
+
def initialize( args )
|
|
16
|
+
check_args( args )
|
|
17
|
+
fred = RubyApp::Fred.new
|
|
18
|
+
case args.first
|
|
19
|
+
when "--feature": fred.my_feature( 10, "Hello", 20 ) { puts "Hello" }
|
|
20
|
+
when "--slow" : fred.my_slow_feature( "World" )
|
|
21
|
+
when "--hosed" : fred.my_hosed_feature( "Boom" ) rescue nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def check_args( args )
|
|
26
|
+
print_usage if !args or args.empty? or !["--feature", "--slow", "--hosed"].include?( args.first )
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def print_usage
|
|
30
|
+
puts "Please enter one of the following options: --feature | --slow | --hosed"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Runner.new( ARGV )
|
|
35
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Mole a feature called 'my_feature' on class Fred
|
|
2
|
+
RubyApp::Fred.mole_after( :feature => :my_feature ) { |context, feature, ret, block, *args|
|
|
3
|
+
::Mole::Moler.mole_it(
|
|
4
|
+
context , # Calling context => Fred instance
|
|
5
|
+
feature , # Method called on Fred => my_feature
|
|
6
|
+
"AppBreaker" , # If we had real user information we would put it here...
|
|
7
|
+
:args => args.join( ", " ), # The args passed into my_feature
|
|
8
|
+
:returned => ret ) # The value returned by my_feature call
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Monitor perf on all instance methods defined on Fred
|
|
12
|
+
RubyApp::Fred.mole_perf do |context, feature, elapsed_time, ret, block, *args|
|
|
13
|
+
::Mole::Moler.perf_it(
|
|
14
|
+
context ,
|
|
15
|
+
"AppBreaker" , # User info
|
|
16
|
+
:controller => context.class.name ,
|
|
17
|
+
:feature => feature ,
|
|
18
|
+
:args => args ,
|
|
19
|
+
:returned => ret ,
|
|
20
|
+
:elapsed_time => "%3.3f" % elapsed_time )
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Monitors unchecked exceptions raise in Fred
|
|
24
|
+
RubyApp::Fred.mole_unchecked do |context, feature, boom, ret, block, *args|
|
|
25
|
+
::Mole::Moler.check_it(
|
|
26
|
+
context ,
|
|
27
|
+
"AppBreaker" , # User info
|
|
28
|
+
:controller => context.class.name,
|
|
29
|
+
:feature => feature ,
|
|
30
|
+
:boom => boom )
|
|
31
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Sample ruby class that is used in our ruby applications
|
|
2
|
+
# We will MOle this class and capture the essence of the interactions
|
|
3
|
+
module RubyApp
|
|
4
|
+
class Fred
|
|
5
|
+
|
|
6
|
+
# Pure feature
|
|
7
|
+
def my_feature( arg1, arg2, arg3, &block )
|
|
8
|
+
"#{arg1}--#{arg2}--#{arg3}"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Slow feature
|
|
12
|
+
def my_slow_feature( arg1 )
|
|
13
|
+
sleep( 2 )
|
|
14
|
+
"slow returned #{arg1}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Hose feature
|
|
18
|
+
def my_hosed_feature( arg1 )
|
|
19
|
+
raise "This will hose your app"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
::Mole.auto_perf( File.join( File.dirname(__FILE__), %w[.. data] ) ) do |context, feature, elapsed_time, ret_val, block, *args|
|
|
2
|
+
::Mole::Moler.perf_it(
|
|
3
|
+
context ,
|
|
4
|
+
"AppBreaker" ,
|
|
5
|
+
:controller => context.class.name,
|
|
6
|
+
:feature => feature ,
|
|
7
|
+
:args => args ,
|
|
8
|
+
:elapsed_time => "%3.3f" % elapsed_time )
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
::Mole.auto_check( File.join( File.dirname(__FILE__), %w[.. data] ) ) do |context, feature, boom, ret_val, block, *args|
|
|
12
|
+
::Mole::Moler.check_it(
|
|
13
|
+
context ,
|
|
14
|
+
"AppBreaker" ,
|
|
15
|
+
:controller => context.class.name,
|
|
16
|
+
:feature => feature ,
|
|
17
|
+
:boom => boom )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
::Mole.auto_mole( File.join( File.dirname(__FILE__), %w[.. data] ) ) do |context, feature, ret, block, *args|
|
|
21
|
+
::Mole::Moler.mole_it(
|
|
22
|
+
context ,
|
|
23
|
+
feature ,
|
|
24
|
+
"AppBreaker",
|
|
25
|
+
:args => context.params[:id] )
|
|
26
|
+
end
|
data/spec/data/blee.rb
CHANGED
data/spec/module_spec.rb
CHANGED
|
@@ -9,12 +9,12 @@ describe Module do
|
|
|
9
9
|
|
|
10
10
|
before( :each ) do
|
|
11
11
|
@blee = Blee.new
|
|
12
|
-
CallStackChecker.reset
|
|
12
|
+
CallStackChecker.reset!
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should trap mole before handler exceptions" do
|
|
16
16
|
Blee.mole_before( :feature => :crap_out ) { |context, feature, *args|
|
|
17
|
-
raise "Before - Something did crap out"
|
|
17
|
+
raise "LEGIT !! - Before - Something did crap out"
|
|
18
18
|
CallStackChecker.called
|
|
19
19
|
}
|
|
20
20
|
@blee.crap_out
|
|
@@ -23,7 +23,7 @@ describe Module do
|
|
|
23
23
|
|
|
24
24
|
it "should trap mole after handler exceptions" do
|
|
25
25
|
Blee.mole_after( :feature => :crap_out ) { |context, feature, *args|
|
|
26
|
-
raise "After - Something did crap out"
|
|
26
|
+
raise "LEGIT !! - After - Something did crap out"
|
|
27
27
|
CallStackChecker.called
|
|
28
28
|
}
|
|
29
29
|
@blee.crap_out
|
|
@@ -32,7 +32,7 @@ describe Module do
|
|
|
32
32
|
|
|
33
33
|
it "should trap mole handler exceptions" do
|
|
34
34
|
Blee.mole_unchecked( :features => [:blee_raise_too] ) { |context, feature, *args|
|
|
35
|
-
raise "Unchecked - Something did crap out"
|
|
35
|
+
raise "-- LEGIT !! - Unchecked - Something did crap out"
|
|
36
36
|
CallStackChecker.called
|
|
37
37
|
}
|
|
38
38
|
@blee.blee_raise_too rescue nil
|
|
@@ -41,7 +41,7 @@ describe Module do
|
|
|
41
41
|
|
|
42
42
|
it "should trap a perf handler exception" do
|
|
43
43
|
Blee.mole_perf( :features => [:blee_slow_too] ) do |context, feature, elapsed_time, args, block|
|
|
44
|
-
raise "Perf - Something did crap out"
|
|
44
|
+
raise "---LEGIT !! - Perf - Something did crap out"
|
|
45
45
|
CallStackChecker.called
|
|
46
46
|
end
|
|
47
47
|
@blee.blee_slow_too
|
|
@@ -124,7 +124,7 @@ describe Module do
|
|
|
124
124
|
args[3].should == "Day"
|
|
125
125
|
CallStackChecker.called
|
|
126
126
|
end
|
|
127
|
-
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
|
127
|
+
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
|
128
128
|
CallStackChecker.should be_called
|
|
129
129
|
end
|
|
130
130
|
|
|
@@ -158,7 +158,7 @@ describe Module do
|
|
|
158
158
|
args[3].should == "Day"
|
|
159
159
|
CallStackChecker.called
|
|
160
160
|
end
|
|
161
|
-
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
|
161
|
+
@blee.blee_block( "Hello", "World", "Good", "Day" ) { "Do it already!!" }
|
|
162
162
|
CallStackChecker.should be_called
|
|
163
163
|
end
|
|
164
164
|
|
|
@@ -172,7 +172,7 @@ describe Module do
|
|
|
172
172
|
elapsed_time.should > 1
|
|
173
173
|
CallStackChecker.called
|
|
174
174
|
end
|
|
175
|
-
@blee.blee_slow
|
|
175
|
+
@blee.blee_slow
|
|
176
176
|
CallStackChecker.should be_called
|
|
177
177
|
end
|
|
178
178
|
|
data/spec/mole_spec.rb
CHANGED
|
@@ -35,7 +35,76 @@ describe Mole do
|
|
|
35
35
|
Mole.dump
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
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
|
|
39
108
|
before( :each ) do
|
|
40
109
|
::Mole.reset_configuration!
|
|
41
110
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,24 +1,60 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w[.. spec_helper] )
|
|
2
|
-
require 'merb'
|
|
3
|
-
require 'action_controller'
|
|
4
2
|
|
|
5
3
|
describe Mole::Utils::Frameworks do
|
|
6
4
|
before( :all ) do
|
|
7
5
|
::Mole.reset_configuration!
|
|
8
6
|
::Mole.initialize( :moleable => true )
|
|
9
7
|
end
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
|
|
9
|
+
describe ".features_for" do
|
|
10
|
+
it "should find the correct features for a merb controller" do
|
|
11
|
+
features = Mole::Utils::Frameworks.features_for( MerbController )
|
|
12
|
+
features.sort.should == %w[blee fred]
|
|
13
|
+
end
|
|
14
|
+
it "should find the correct features for a rails controller" do
|
|
15
|
+
features = Mole::Utils::Frameworks.features_for( RailsController )
|
|
16
|
+
features.sort.should == %w[blee fred]
|
|
17
|
+
end
|
|
18
|
+
it "should find the correct features for a plain old ruby object" do
|
|
19
|
+
features = Mole::Utils::Frameworks.features_for( Poro )
|
|
20
|
+
features.sort.should == %w[blee duh]
|
|
21
|
+
end
|
|
14
22
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
describe ".merb_actions" do
|
|
25
|
+
it "should retrieve Merb controller actions correctly" do
|
|
26
|
+
actions = Mole::Utils::Frameworks.merb_actions( MerbController )
|
|
27
|
+
actions.sort.should == %w[blee fred]
|
|
28
|
+
end
|
|
29
|
+
it "should raise an exception if it is not a merb controller" do
|
|
30
|
+
lambda { Mole::Utils::Frameworks.merb_actions( String ) }.should raise_error( "Invalid Merb Controller class `String" )
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe ".rails_actions" do
|
|
35
|
+
it "should retrieve Rails controller actions correctly" do
|
|
36
|
+
actions = Mole::Utils::Frameworks.rails_actions( RailsController )
|
|
37
|
+
actions.sort.should == %w[blee fred]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should raise an exception if it is not a rails controller" do
|
|
41
|
+
lambda { Mole::Utils::Frameworks.rails_actions( String ) }.should raise_error( "Invalid Rails Controller class `String" )
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Poro
|
|
46
|
+
def blee
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def duh
|
|
50
|
+
end
|
|
19
51
|
end
|
|
20
52
|
|
|
21
|
-
class MerbController
|
|
53
|
+
class MerbController
|
|
54
|
+
def self.callable_actions
|
|
55
|
+
{ 'fred' => nil, 'blee' => nil }
|
|
56
|
+
end
|
|
57
|
+
|
|
22
58
|
def fred
|
|
23
59
|
end
|
|
24
60
|
|
|
@@ -31,7 +67,11 @@ describe Mole::Utils::Frameworks do
|
|
|
31
67
|
end
|
|
32
68
|
end
|
|
33
69
|
|
|
34
|
-
class RailsController
|
|
70
|
+
class RailsController
|
|
71
|
+
def self.action_methods
|
|
72
|
+
%w[fred blee]
|
|
73
|
+
end
|
|
74
|
+
|
|
35
75
|
def fred
|
|
36
76
|
end
|
|
37
77
|
|