Permalink
Browse files

Spec out the rest of the functionality.

There is one, legit, failing spec. The flash and authenticity token
settings are also left untested, as they will soon change.
  • Loading branch information...
oggy committed Mar 31, 2011
1 parent 5983e4f commit 0a4e8efcbab3e3800a41ad6b5a6d2538c2920f59
Showing with 500 additions and 58 deletions.
  1. +21 −9 spec/support/progressive_rendering_test.rb
  2. +479 −49 spec/template_streaming_spec.rb
@@ -9,7 +9,7 @@ def self.included(base)
def setup_progressive_rendering_test
ActionController::Base.session = {:key => "_", :secret => "x"*30}
ActionController::Routing::Routes.clear!
- ActionController::Routing::Routes.add_route('/', :controller => 'test')
+ ActionController::Routing::Routes.add_route('/', :controller => 'test', :action => 'action')
push_constant_value Object, :TestController, Class.new(Controller)
TestController.view_paths = [VIEW_PATH]
@@ -31,11 +31,27 @@ def teardown_progressive_rendering_test
end
def view(text)
- write_file("#{controller.view_paths.first}/test/index.html.erb", text)
+ template("test/action", text)
end
def layout(text)
- write_file("#{controller.view_paths.first}/layouts/test.html.erb", text)
+ template("layouts/layout", text)
+ end
+
+ def partial(text)
+ template("test/_partial", text)
+ end
+
+ def template(template_path, text)
+ path = "#{controller.view_paths.first}/#{template_path}.html.erb"
+ FileUtils.mkdir_p File.dirname(path)
+ open(path, 'w') { |f| f.print text }
+ end
+
+ def action(&block)
+ TestController.class_eval do
+ define_method(:action, &block)
+ end
end
def run(env_overrides={})
@@ -50,11 +66,6 @@ def run(env_overrides={})
attr_reader :status, :headers, :body, :data
- def write_file(path, content)
- FileUtils.mkdir_p File.dirname(path)
- open(path, 'w') { |f| f.print content }
- end
-
def default_env
{
'REQUEST_METHOD' => 'GET',
@@ -75,7 +86,7 @@ def default_env
end
class Controller < ActionController::Base
- def index
+ def action
end
def rescue_action(exception)
@@ -106,5 +117,6 @@ def chunks(*chunks)
end
include Helpers
+ Controller.send :include, Helpers
ActionView::Base.send :include, Helpers
end
Oops, something went wrong.

0 comments on commit 0a4e8ef

Please sign in to comment.