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.
Files changed (104) hide show
  1. data/Manifest.txt +92 -0
  2. data/README.txt +10 -7
  3. data/lib/mole.rb +63 -1
  4. data/lib/mole/module.rb +136 -124
  5. data/lib/mole/utils/frameworks.rb +32 -7
  6. data/lib/mole/version.rb +1 -1
  7. data/notes/notes.txt +1 -0
  8. data/samples/merbapp/README +14 -0
  9. data/samples/merbapp/Rakefile +124 -0
  10. data/samples/merbapp/app/controllers/application.rb +3 -0
  11. data/samples/merbapp/app/controllers/exceptions.rb +13 -0
  12. data/samples/merbapp/app/controllers/moled.rb +25 -0
  13. data/samples/merbapp/app/helpers/global_helper.rb +5 -0
  14. data/samples/merbapp/app/mailers/views/layout/application.html.erb +1 -0
  15. data/samples/merbapp/app/mailers/views/layout/application.text.erb +1 -0
  16. data/samples/merbapp/app/parts/views/layout/application.html.erb +1 -0
  17. data/samples/merbapp/app/views/exceptions/internal_server_error.html.erb +216 -0
  18. data/samples/merbapp/app/views/exceptions/not_acceptable.html.erb +38 -0
  19. data/samples/merbapp/app/views/exceptions/not_found.html.erb +40 -0
  20. data/samples/merbapp/app/views/layout/application.html.erb +11 -0
  21. data/samples/merbapp/app/views/moled/index.html.erb +5 -0
  22. data/samples/merbapp/app/views/moled/result.html.erb +5 -0
  23. data/samples/merbapp/config/boot.rb +11 -0
  24. data/samples/merbapp/config/dependencies.rb +41 -0
  25. data/samples/merbapp/config/environments/development.rb +1 -0
  26. data/samples/merbapp/config/environments/production.rb +1 -0
  27. data/samples/merbapp/config/environments/test.rb +1 -0
  28. data/samples/merbapp/config/merb.yml +82 -0
  29. data/samples/merbapp/config/merb_init.rb +26 -0
  30. data/samples/merbapp/config/mole_config.rb +33 -0
  31. data/samples/merbapp/config/router.rb +38 -0
  32. data/samples/merbapp/config/upload.conf +0 -0
  33. data/samples/merbapp/log/merb.4000.pid +1 -0
  34. data/samples/merbapp/public/images/merb.jpg +0 -0
  35. data/samples/merbapp/public/merb.fcgi +6 -0
  36. data/samples/merbapp/public/stylesheets/master.css +119 -0
  37. data/samples/merbapp/script/destroy +32 -0
  38. data/samples/merbapp/script/generate +32 -0
  39. data/samples/merbapp/script/stop_merb +13 -0
  40. data/samples/merbapp/spec/spec_helper.rb +15 -0
  41. data/samples/merbapp/test/test_helper.rb +14 -0
  42. data/samples/railsapp/README +14 -0
  43. data/samples/railsapp/Rakefile +10 -0
  44. data/samples/railsapp/app/controllers/application.rb +13 -0
  45. data/samples/railsapp/app/controllers/moled_controller.rb +23 -0
  46. data/samples/railsapp/app/helpers/application_helper.rb +3 -0
  47. data/samples/railsapp/app/views/moled/index.html.erb +5 -0
  48. data/samples/railsapp/app/views/moled/result.html.erb +5 -0
  49. data/samples/railsapp/config/boot.rb +109 -0
  50. data/samples/railsapp/config/database.yml +13 -0
  51. data/samples/railsapp/config/environment.rb +59 -0
  52. data/samples/railsapp/config/environments/development.rb +18 -0
  53. data/samples/railsapp/config/environments/production.rb +20 -0
  54. data/samples/railsapp/config/environments/test.rb +22 -0
  55. data/samples/railsapp/config/initializers/inflections.rb +10 -0
  56. data/samples/railsapp/config/initializers/mime_types.rb +5 -0
  57. data/samples/railsapp/config/initializers/mole.rb +10 -0
  58. data/samples/railsapp/config/moles/mole_config.rb +44 -0
  59. data/samples/railsapp/config/routes.rb +35 -0
  60. data/samples/railsapp/doc/README_FOR_APP +2 -0
  61. data/samples/railsapp/log/development.log +3554 -0
  62. data/samples/railsapp/log/production.log +643 -0
  63. data/samples/railsapp/log/server.log +0 -0
  64. data/samples/railsapp/log/test.log +0 -0
  65. data/samples/railsapp/public/.htaccess +40 -0
  66. data/samples/railsapp/public/404.html +30 -0
  67. data/samples/railsapp/public/422.html +30 -0
  68. data/samples/railsapp/public/500.html +30 -0
  69. data/samples/railsapp/public/dispatch.cgi +10 -0
  70. data/samples/railsapp/public/dispatch.fcgi +24 -0
  71. data/samples/railsapp/public/dispatch.rb +10 -0
  72. data/samples/railsapp/public/favicon.ico +0 -0
  73. data/samples/railsapp/public/images/rails.png +0 -0
  74. data/samples/railsapp/public/javascripts/application.js +2 -0
  75. data/samples/railsapp/public/javascripts/controls.js +963 -0
  76. data/samples/railsapp/public/javascripts/dragdrop.js +972 -0
  77. data/samples/railsapp/public/javascripts/effects.js +1120 -0
  78. data/samples/railsapp/public/javascripts/prototype.js +4225 -0
  79. data/samples/railsapp/public/robots.txt +5 -0
  80. data/samples/railsapp/script/about +3 -0
  81. data/samples/railsapp/script/console +3 -0
  82. data/samples/railsapp/script/destroy +3 -0
  83. data/samples/railsapp/script/generate +3 -0
  84. data/samples/railsapp/script/performance/benchmarker +3 -0
  85. data/samples/railsapp/script/performance/profiler +3 -0
  86. data/samples/railsapp/script/performance/request +3 -0
  87. data/samples/railsapp/script/plugin +3 -0
  88. data/samples/railsapp/script/process/inspector +3 -0
  89. data/samples/railsapp/script/process/reaper +3 -0
  90. data/samples/railsapp/script/process/spawner +3 -0
  91. data/samples/railsapp/script/runner +3 -0
  92. data/samples/railsapp/script/server +3 -0
  93. data/samples/railsapp/test/test_helper.rb +38 -0
  94. data/samples/rubyapp/README +22 -0
  95. data/samples/rubyapp/bin/ruby_app +35 -0
  96. data/samples/rubyapp/config/mole_conf.rb +31 -0
  97. data/samples/rubyapp/lib/fred.rb +22 -0
  98. data/spec/config/auto_mole_config.rb +26 -0
  99. data/spec/data/blee.rb +1 -1
  100. data/spec/module_spec.rb +8 -8
  101. data/spec/mole_spec.rb +70 -1
  102. data/spec/spec_helper.rb +1 -1
  103. data/spec/utils/framework_spec.rb +52 -12
  104. metadata +154 -53
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ 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/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/performance/request'
@@ -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/process/inspector'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/reaper'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/spawner'
@@ -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,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
@@ -11,7 +11,7 @@ class Blee
11
11
  end
12
12
 
13
13
  def blee_no_args
14
- # puts ">>> Blee_No_Args"
14
+ 10
15
15
  end
16
16
 
17
17
  def blee_args( a, b, c, d )
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!!" } rescue nil
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!!" } rescue nil
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 rescue nil
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
- describe "load_mole_configuration" do
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
@@ -20,7 +20,7 @@ class CallStackChecker
20
20
  @called = 1
21
21
  end
22
22
 
23
- def reset
23
+ def reset!
24
24
  @called = 0
25
25
  end
26
26
 
@@ -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
- it "should retrieve Merb controller actions correctly" do
12
- actions = Mole::Utils::Frameworks.merb_actions( MerbController )
13
- actions.sort.should == %w[blee fred]
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
- it "should retrieve Rails controller actions correctly" do
17
- actions = Mole::Utils::Frameworks.rails_actions( RailsController )
18
- actions.sort.should == %w[blee fred]
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 < Merb::Controller
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 < ActionController::Base
70
+ class RailsController
71
+ def self.action_methods
72
+ %w[fred blee]
73
+ end
74
+
35
75
  def fred
36
76
  end
37
77