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
Public specs for display object method. Pending api specifications on 
default html mime type.
lancecarlson (author)
Wed Feb 06 01:16:08 -0800 2008
Yehuda Katz (committer)
Wed Feb 06 16:31:25 -0800 2008
commit  cc02813d9eca3b5dec5d216a6ec653cf7a05c359
tree    745b9a05c34d95ac2d9e1dd9d962ab91c2a8e747
parent  a0b5545a7be446c532b5b31c2dfa2aa0943b055f
...
156
157
158
 
 
159
160
161
162
163
164
165
...
156
157
158
159
160
161
162
 
 
163
164
165
0
@@ -156,10 +156,10 @@ class Merb::AbstractController
0
     @_caught_content = {}
0
   end
0
   
0
+ # This will dispatch the request, calling before and after dispatch hooks
0
+ #
0
   # ==== Parameters
0
   # action<~to_s>:: The action to dispatch to. This will be #send'ed in _call_action
0
-
0
- # DOC: Yehuda Katz FAILED
0
   def _dispatch(action=:to_s)
0
     hook :before_dispatch
0
     self.action_name = action
...
142
143
144
145
 
146
147
148
 
149
150
151
...
142
143
144
 
145
146
147
 
148
149
150
151
0
@@ -142,10 +142,10 @@ module Merb::RenderMixin
0
     # Figure out what to transform and raise NotAcceptable unless there's a transform method assigned
0
     transform = Merb.mime_transform_method(content_type)
0
     raise NotAcceptable unless transform && object.respond_to?(transform)
0
-
0
+
0
     # Throw the transformed object for later consumption by the layout
0
     throw_content(:for_layout, object.send(transform))
0
-
0
+
0
     # Only use a layout if one was specified
0
     if opts[:layout]
0
       # Look for the layout under the default layout directly. If it's not found, reraise
...
4
5
6
 
 
7
8
9
10
11
 
12
 
13
14
15
16
17
 
18
 
19
20
21
22
23
 
24
25
 
 
26
27
28
...
4
5
6
7
8
9
10
11
12
 
13
14
15
16
17
18
19
 
20
21
22
23
24
25
26
 
27
28
 
29
30
31
32
33
0
@@ -4,25 +4,30 @@ module Merb::Test::Fixtures
0
 
0
   module Abstract
0
     
0
+ class SomeModel; end
0
+
0
     class Testing < Merb::AbstractController
0
       self._template_root = File.dirname(__FILE__) / "views"
0
     end
0
     
0
- class DisplayObject < Testing
0
+ class DisplayObject < Testing
0
       def index
0
+ @obj = SomeModel.new
0
         display @obj
0
       end
0
     end
0
     
0
- class DisplayObjectWithSymbol < Testing
0
+ class DisplayObjectWithAction < Testing
0
       def create
0
+ @obj = SomeModel.new
0
         display @obj, :new
0
       end
0
     end
0
     
0
- class DisplayObjectWithString < Testing
0
+ class DisplayObjectWithPath < Testing
0
       def index
0
- display @obj, "full/path/to/template"
0
+ @obj = SomeModel.new
0
+ display @obj, "test_display/foo.html"
0
       end
0
     end
0
     
...
11
12
13
14
 
15
16
17
...
11
12
13
 
14
15
16
17
0
@@ -11,7 +11,7 @@ module Merb::Test::Fixtures
0
     class RenderString < Testing
0
       
0
       def index
0
- render "index"
0
+ render "the index"
0
       end
0
     end
0
 
...
1
2
 
3
...
 
1
2
3
0
@@ -1 +1 @@
0
-index
0
\ No newline at end of file
0
+the index
0
\ No newline at end of file
...
1
2
 
3
...
 
1
2
3
0
@@ -1 +1 @@
0
-index
0
\ No newline at end of file
0
+the index
0
\ No newline at end of file
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+fooness
0
\ No newline at end of file
...
1
2
3
 
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
11
12
13
14
...
1
2
 
3
4
5
6
7
8
 
 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -1,13 +1,21 @@
0
 require File.join(File.dirname(__FILE__), "spec_helper")
0
 
0
-describe Merb::AbstractController, " displaying objects" do
0
+describe Merb::AbstractController, " displaying objects with templates" do
0
 
0
   before do
0
     Merb.push_path(:layout, File.dirname(__FILE__) / "controllers" / "views" / "layouts")
0
   end
0
   
0
- it "should support displaying objects with no layout" do
0
- dispatch_should_make_body("DisplayObject", "index")
0
+ it "should allow you to pass an object" do
0
+ dispatch_should_make_body("DisplayObject", "the index")
0
+ end
0
+
0
+ it "should allow you to pass an object with an action specified" do
0
+ dispatch_should_make_body("DisplayObjectWithAction", "new action", :create)
0
+ end
0
+
0
+ it "should allow you to pass an object with a path specified for the template" do
0
+ dispatch_should_make_body("DisplayObjectWithPath", "fooness")
0
   end
0
   
0
 end
0
\ No newline at end of file
...
7
8
9
10
 
11
12
13
14
 
15
16
17
18
 
19
20
21
22
 
23
24
25
...
27
28
29
30
 
31
32
33
34
 
35
36
37
38
 
39
40
41
42
 
43
44
45
46
...
7
8
9
 
10
11
12
13
 
14
15
16
17
 
18
19
20
21
 
22
23
24
25
...
27
28
29
 
30
31
32
33
 
34
35
36
37
 
38
39
40
41
 
42
43
44
45
46
0
@@ -7,19 +7,19 @@ describe Merb::AbstractController, " rendering plain strings" do
0
   end
0
 
0
   it "should support rendering plain strings with no layout" do
0
- dispatch_should_make_body("RenderString", "index")
0
+ dispatch_should_make_body("RenderString", "the index")
0
   end
0
 
0
   it "should support rendering plain strings with custom layouts" do
0
- dispatch_should_make_body("RenderStringCustomLayout", "Custom: index")
0
+ dispatch_should_make_body("RenderStringCustomLayout", "Custom: the index")
0
   end
0
 
0
   it "should support rendering plain strings with the application layout" do
0
- dispatch_should_make_body("RenderStringAppLayout", "App: index")
0
+ dispatch_should_make_body("RenderStringAppLayout", "App: the index")
0
   end
0
   
0
   it "should support rendering plain strings with the controller layout" do
0
- dispatch_should_make_body("RenderStringControllerLayout", "Controller: index")
0
+ dispatch_should_make_body("RenderStringControllerLayout", "Controller: the index")
0
   end
0
 
0
 end
0
@@ -27,19 +27,19 @@ end
0
 describe Merb::AbstractController, " rendering templates" do
0
 
0
   it "should support rendering templates with no layout" do
0
- dispatch_should_make_body("RenderTemplate", "index")
0
+ dispatch_should_make_body("RenderTemplate", "the index")
0
   end
0
 
0
   it "should support rendering templates with custom layouts" do
0
- dispatch_should_make_body("RenderStringCustomLayout", "Custom: index")
0
+ dispatch_should_make_body("RenderStringCustomLayout", "Custom: the index")
0
   end
0
   
0
   it "should support rendering templates with the application layout" do
0
- dispatch_should_make_body("RenderTemplateAppLayout", "App: index")
0
+ dispatch_should_make_body("RenderTemplateAppLayout", "App: the index")
0
   end
0
   
0
   it "should support rendering plain strings with the controller layout" do
0
- dispatch_should_make_body("RenderTemplateControllerLayout", "Controller: index")
0
+ dispatch_should_make_body("RenderTemplateControllerLayout", "Controller: the index")
0
   end
0
 
0
 end
0
\ No newline at end of file
...
9
10
11
 
12
13
14
15
16
17
 
18
19
20
...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -9,12 +9,14 @@ require File.join(__DIR__, "controllers", "display")
0
 Merb.start :environment => 'test', :adapter => 'runner'
0
 
0
 module Merb::Test::Behaviors
0
+ include Merb::Test::RequestHelper
0
   
0
   def dispatch_should_make_body(klass, body, action = :index)
0
     controller = Merb::Test::Fixtures::Abstract.const_get(klass).new
0
     controller._dispatch(action.to_s)
0
     controller.body.should == body
0
   end
0
+
0
 end
0
 
0
 Spec::Runner.configure do |config|
...
4
5
6
 
7
8
9
...
4
5
6
7
8
9
10
0
@@ -4,5 +4,6 @@ require File.join(__DIR__, "..", "..", "spec_helper")
0
 
0
 require File.join(__DIR__, "controllers", "base")
0
 require File.join(__DIR__, "controllers", "responder")
0
+require File.join(__DIR__, "controllers", "display")
0
 
0
 Merb.start :environment => 'test', :adapter => 'runner'
0
\ No newline at end of file

Comments

    No one has commented yet.