Permalink
Browse files

FINALLY figured out how to restore ability for isolated controller specs

to ignore the absence of templates.
  • Loading branch information...
1 parent fc5cf35 commit 7feca16933347518228e2db73a54a910b35db503 @dchelimsky committed Jun 22, 2009
@@ -166,8 +166,15 @@ def _pick_template(*args)
end
def render(*args)
- return super if Hash === args.last && args.last[:inline]
- @_rendered ? record_render(args[0]) : super
+ if file = args.last[:file].instance_eval{@template_path}
+ record_render :file => file
+ elsif args.last[:inline]
+ super
+ elsif @_rendered
+ record_render(args[0])
+ else
+ super
+ end
end
private
@@ -213,6 +220,19 @@ def render(options=nil, extra_options={}, &block)
end
end
+ # Rails 2.3
+ def default_template(action_name = self.action_name)
+ if integrate_views?
+ super
+ else
+ begin
+ super
+ rescue ActionView::MissingTemplate
+ "#{self.class.name.sub(/Controller$/,'').underscore}/#{action_name}"
+ end
+ end
+ end
+
def response(&block)
# NOTE - we're setting @update for the assert_select_spec - kinda weird, huh?
@update = block
@@ -13,6 +13,9 @@ def some_action
render :template => "template/that/does/not/actually/exist"
end
+ def some_action_with_implied_template
+ end
+
def action_with_template
render :template => "controller_spec/action_with_template"
end
@@ -105,11 +108,11 @@ class UnRescuedError < Exception; end
end
def rescued_error_action
- raise RescuedError
+ raise ControllerSpecController::RescuedError
end
def un_rescued_error_action
- raise UnRescuedError
+ raise ControllerSpecController::UnRescuedError
end
end
@@ -4,12 +4,18 @@
describe "a controller spec running in isolation mode", :type => :controller do
controller_name :controller_spec
- it "should not care if the template doesn't exist" do
+ it "should not care if the specified template doesn't exist" do
get 'some_action'
response.should be_success
response.should render_template("template/that/does/not/actually/exist")
end
+ it "should not care if the implied template doesn't exist" do
+ get 'some_action_with_implied_template'
+ response.should be_success
+ response.should render_template("some_action_with_implied_template")
+ end
+
it "should not care if the template has errors" do
get 'action_with_errors_in_template'
response.should be_success

0 comments on commit 7feca16

Please sign in to comment.