GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Very close to controllers working
wycats (author)
Mon Jan 14 16:03:32 -0800 2008
commit  39791e6fb09a30e2ae960ef7f95e4510d35a7c72
tree    17df18612576a257ad8235850a2233c35ea4f05b
parent  e0452c7168ea23d1bb510ed958cf69acf33b1933
...
7
8
9
 
10
11
12
13
14
 
15
16
17
...
19
20
21
 
22
23
24
...
7
8
9
10
11
12
13
14
 
15
16
17
18
...
20
21
22
23
24
25
26
0
@@ -7,11 +7,12 @@ module Merb
0
   autoload :ControllerExceptions, "merb_core/controller/exceptions"
0
   autoload :Dispatcher, "merb_core/dispatch/dispatcher"
0
   autoload :ErubisCaptureMixin, "merb_core/controller/mixins/erubis_capture"
0
+ autoload :Hook, "merb_core/hook"
0
   autoload :Plugins, "merb_core/plugins"
0
   autoload :Rack, "merb_core/rack"
0
   autoload :RenderMixin, "merb_core/controller/mixins/render"
0
   autoload :Request, "merb_core/dispatch/request"
0
- autoload :Responder, "merb_core/controller/mixins/responder"
0
+ autoload :ResponderMixin, "merb_core/controller/mixins/responder"
0
   autoload :Router, "merb_core/dispatch/router"
0
   autoload :SessionMixin, "merb_core/dispatch/session"
0
 end
0
@@ -19,6 +20,7 @@ end
0
 # Require this rather than autoloading it so we can be sure the default templater
0
 # gets registered
0
 require "merb_core/controller/template"
0
+require "merb_core/hook"
0
 
0
 module Merb
0
   module InlineTemplates; end
...
62
63
64
 
65
66
67
...
127
128
129
130
 
 
 
 
 
 
131
132
133
...
140
141
142
 
143
144
145
...
149
150
151
152
 
153
154
155
...
161
162
163
 
164
165
166
...
62
63
64
65
66
67
68
...
128
129
130
 
131
132
133
134
135
136
137
138
139
...
146
147
148
149
150
151
152
...
156
157
158
 
159
160
161
162
...
168
169
170
171
172
173
174
0
@@ -62,6 +62,7 @@
0
 class Merb::AbstractController
0
   include Merb::RenderMixin
0
   include Merb::InlineTemplates
0
+ is_hookable
0
   
0
   class_inheritable_accessor :_before_filters, :_after_filters, :_template_root, :_layout
0
 
0
@@ -127,7 +128,12 @@ class Merb::AbstractController
0
     end
0
   end
0
   
0
- attr_accessor :_benchmarks, :_thrown_content, :_body
0
+ attr_accessor :_benchmarks, :_thrown_content
0
+
0
+ #---
0
+ # @semipublic
0
+ attr_accessor :body
0
+
0
   _attr_accessor :action_name
0
   
0
   # ==== Parameters
0
@@ -140,6 +146,7 @@ class Merb::AbstractController
0
   # ==== Parameters
0
   # action<~to_s>:: The action to dispatch to. This will be #send'ed in _call_action
0
   def _dispatch(action=:to_s)
0
+ hook :before_dispatch
0
     self.action_name = action
0
     
0
     caught = catch(:halt) do
0
@@ -149,7 +156,7 @@ class Merb::AbstractController
0
       result
0
     end
0
   
0
- @_body = case caught
0
+ @body = case caught
0
     when :filter_chain_completed then _call_action(action_name)
0
     when String then caught
0
     when nil then _filters_halted
0
@@ -161,6 +168,7 @@ class Merb::AbstractController
0
     start = Time.now
0
     _call_filters(_after_filters)
0
     @_benchmarks[:after_filters_time] = Time.now - start if _after_filters
0
+ hook :after_dispatch
0
   end
0
   
0
   # This method exists to provide an overridable hook for ActionArgs
...
231
232
233
234
 
235
236
237
...
231
232
233
 
234
235
236
237
0
@@ -231,7 +231,7 @@ module Merb
0
           raise ContentTypeAlreadySet, "Cannot modify provided_formats because content_type has already been set"
0
         end
0
         formats.each do |fmt|
0
- self._provided_formats << fmt unless provided_formats.include?(fmt)
0
+ _provided_formats << fmt unless _provided_formats.include?(fmt)
0
         end
0
       end
0
 
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
43
0
@@ -38,31 +38,5 @@ module Merb
0
       }) unless defined?(DEFAULT_ENV)
0
     end
0
 
0
- module RequestHelper
0
-
0
- # ==== Parameters
0
- # env<Hash>:: A hash of environment keys to be merged into the default list
0
- # opt<Hash>:: A hash of options (see below)
0
- #
0
- # ==== Options (choose one)
0
- # :post_body<String>:: The post body for the request
0
- # :body<String>:: The body for the request
0
- #
0
- # ==== Returns
0
- # FakeRequest:: A Request object that is built based on the parameters
0
- #
0
- # ==== Note
0
- # If you pass a post_body, the content-type will be set as URL-encoded
0
- def fake_request(env = {}, opt = {})
0
- if opt[:post_body]
0
- req = opt[:post_body]
0
- env.merge!(:content_type => "application/x-www-form-urlencoded")
0
- else
0
- req = opt[:req] || ""
0
- end
0
- FakeRequest.new(env, StringIO.new(req))
0
- end
0
- end
0
   end
0
-
0
 end
0
\ No newline at end of file
...
1
2
3
4
5
6
 
7
...
 
 
 
 
 
1
2
3
0
@@ -1,5 +1 @@
0
-require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
0
-
0
-Spec::Runner.configure do |config|
0
- config.include Merb::Test::RequestHelper
0
-end
0
\ No newline at end of file
0
+require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
0
\ No newline at end of file
...
4
5
6
7
 
8
9
10
11
 
12
13
14
...
21
22
23
24
 
25
26
27
...
30
31
32
33
 
34
35
36
...
60
61
62
63
 
64
65
66
67
 
68
69
70
...
73
74
75
76
 
77
78
79
...
95
96
97
98
 
99
100
101
...
4
5
6
 
7
8
9
10
 
11
12
13
14
...
21
22
23
 
24
25
26
27
...
30
31
32
 
33
34
35
36
...
60
61
62
 
63
64
65
66
 
67
68
69
70
...
73
74
75
 
76
77
78
79
...
95
96
97
 
98
99
100
101
0
@@ -4,11 +4,11 @@
0
 # and that other features (or lack thereof), are not causing tests to fail
0
 # that would otherwise pass.
0
 module Merb::Test::Fixtures
0
- class Testing < Merb::AbstractController
0
+ class AbstractTesting < Merb::AbstractController
0
     self._template_root = File.dirname(__FILE__) / "views"
0
   end
0
   
0
- class TestBeforeFilter < Testing
0
+ class TestBeforeFilter < AbstractTesting
0
     before :foo
0
 
0
     def index
0
@@ -21,7 +21,7 @@ module Merb::Test::Fixtures
0
     end
0
   end
0
 
0
- class TestAfterFilter < Testing
0
+ class TestAfterFilter < AbstractTesting
0
     after :foo
0
 
0
     def index
0
@@ -30,7 +30,7 @@ module Merb::Test::Fixtures
0
       
0
     private
0
     def foo
0
- @_body = "foo filter"
0
+ @body = "foo filter"
0
     end
0
   end
0
 
0
@@ -60,11 +60,11 @@ module Merb::Test::Fixtures
0
     
0
     private
0
     def bar
0
- @_body = "bar filter"
0
+ @body = "bar filter"
0
     end
0
   end
0
   
0
- class TestProcFilter < Testing
0
+ class TestProcFilter < AbstractTesting
0
     before { @x = "proc filter1" }
0
     before Proc.new { @y = "proc filter2" }
0
     
0
@@ -73,7 +73,7 @@ module Merb::Test::Fixtures
0
     end
0
   end
0
   
0
- class TestExcludeFilter < Testing
0
+ class TestExcludeFilter < AbstractTesting
0
     before :foo, :exclude => :index
0
     before :bar, :exclude => [:index]
0
     
0
@@ -95,7 +95,7 @@ module Merb::Test::Fixtures
0
     end
0
   end
0
   
0
- class TestOnlyFilter < Testing
0
+ class TestOnlyFilter < AbstractTesting
0
     before :foo, :only => :index
0
     before :bar, :only => [:index]
0
     
...
1
2
 
3
4
5
6
 
7
8
9
...
17
18
19
20
 
21
22
23
...
1
 
2
3
4
5
 
6
7
8
9
...
17
18
19
 
20
21
22
23
0
@@ -1,9 +1,9 @@
0
 module Merb::Test::Fixtures
0
- class Testing < Merb::AbstractController
0
+ class AbstractTesting < Merb::AbstractController
0
     self._template_root = File.dirname(__FILE__) / "views"
0
   end
0
 
0
- class TestRenderString < Testing
0
+ class TestRenderString < AbstractTesting
0
     def index
0
       render "index"
0
     end
0
@@ -17,7 +17,7 @@ module Merb::Test::Fixtures
0
 
0
   class TestRenderStringControllerLayout < TestRenderString; end
0
   
0
- class TestRenderTemplate < Testing
0
+ class TestRenderTemplate < AbstractTesting
0
     def index
0
       render
0
     end
...
48
49
50
51
 
52
53
54
...
48
49
50
 
51
52
53
54
0
@@ -48,7 +48,7 @@ describe Merb::AbstractController, " should support before and after filters" do
0
   
0
   it "should throw an error if both :exclude and :only are passed to a filter" do
0
     running { Merb::Test::Fixtures.class_eval do
0
- class TestErrorFilter < Merb::Test::Fixtures::Testing
0
+ class TestErrorFilter < Merb::Test::Fixtures::AbstractTesting
0
         before :foo, :only => :index, :exclude => :show
0
       end
0
     end }.should raise_error(ArgumentError, /either :only or :exclude/)
...
2
3
4
 
 
 
 
5
6
7
...
28
29
30
 
 
 
 
31
32
33
...
2
3
4
5
6
7
8
9
10
11
...
32
33
34
35
36
37
38
39
40
41
0
@@ -2,6 +2,10 @@ require File.join(File.dirname(__FILE__), "spec_helper")
0
 
0
 describe Merb::AbstractController, " rendering plain strings" do
0
 
0
+ before do
0
+ Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
0
+ end
0
+
0
   it "should support rendering plain strings with no layout" do
0
     dispatch_should_make_body("TestRenderString", "index")
0
   end
0
@@ -28,6 +32,10 @@ end
0
 
0
 describe Merb::AbstractController, " rendering templates" do
0
 
0
+ before do
0
+ Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
0
+ end
0
+
0
   it "should support rendering templates with no layout" do
0
     dispatch_should_make_body("TestRenderTemplate", "index")
0
   end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
21
22
23
...
 
 
1
 
2
3
4
5
 
6
7
8
9
10
11
 
12
13
14
 
15
16
17
18
0
@@ -1,23 +1,18 @@
0
-require 'rubygems'
0
-require 'ruby-debug'
0
 __DIR__ = File.dirname(__FILE__)
0
-
0
 require File.join(__DIR__, "..", "..", "spec_helper")
0
 
0
 # The framework structure *must* be set up before loading in framework
0
 # files.
0
-Merb.push_path(:layout, __DIR__ / "controllers" / "views" / "layouts")
0
 require File.join(__DIR__, "controllers", "filters")
0
 require File.join(__DIR__, "controllers", "render")
0
 
0
 Merb::BootLoader::Templates.new.run
0
 
0
 module Merb::Test::Behaviors
0
-
0
   def dispatch_should_make_body(klass, body, action = :index)
0
     controller = Merb::Test::Fixtures.const_get(klass).new
0
     controller._dispatch(action)
0
- controller._body.should == body
0
+ controller.body.should == body
0
   end
0
 end
0
 
...
2
3
4
 
5
6
7
8
9
10
11
12
...
52
53
54
55
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
66
 
 
 
67
68
...
2
3
4
5
6
7
8
9
 
10
11
12
...
52
53
54
 
55
56
57
58
59
60
61
62
63
64
 
 
 
 
 
 
 
65
66
67
68
69
0
@@ -2,11 +2,11 @@ $TESTING=true
0
 
0
 require File.join(File.dirname(__FILE__), "..", "lib", "merb")
0
 require 'merb_core/test/fake_request'
0
+require 'merb_core/test/request_helper'
0
 Merb.environment = "test"
0
 Merb.logger = Merb::Logger.new(Merb.dir_for(:log) / "test_log")
0
 Merb.logger.level = Merb::Logger.const_get(Merb::Config[:log_level].upcase) rescue Merb::Logger::INFO
0
 
0
-
0
 # -- Global custom matchers --
0
 
0
 # A better +be_kind_of+ with more informative error messages.
0
@@ -52,16 +52,17 @@ module Merb
0
       end
0
     end
0
         
0
- module Helper; end
0
+ module Helper
0
+ def running(&blk) blk; end
0
+ def executing(&blk) blk; end
0
+ def doing(&blk) blk; end
0
+ def calling(&blk) blk; end
0
+ end
0
   end
0
 end
0
 
0
 Spec::Runner.configure do |config|
0
- config.include(Merb::Test::Helper)
0
- config.include(Merb::Test::RspecMatchers)
0
- Spec::Example::ExampleGroup.class_eval do
0
- def running(&blk) blk; end
0
- def executing(&blk) blk; end
0
- def doing(&blk) blk; end
0
- end
0
+ config.include Merb::Test::Helper
0
+ config.include Merb::Test::RspecMatchers
0
+ config.include Merb::Test::RequestHelper
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.