<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -43,7 +43,7 @@ module Spec
       #
       class ControllerExampleGroup &lt; FunctionalExampleGroup
         class &lt;&lt; self
-                    
+
           # Use integrate_views to instruct RSpec to render views in
           # your controller examples in Integration mode.
           #
@@ -56,11 +56,11 @@ module Spec
           def integrate_views(integrate_views = true)
             @integrate_views = integrate_views
           end
-          
+
           def integrate_views? # :nodoc:
             @integrate_views
           end
-          
+
           def inherited(klass) # :nodoc:
             klass.integrate_views(integrate_views?)
             klass.subject { controller }
@@ -93,7 +93,7 @@ module Spec
             tests &quot;#{name}_controller&quot;.camelize.constantize
           end
         end
-        
+
         before(:each) do
           # Some Rails apps explicitly disable ActionMailer in environment.rb
           if defined?(ActionMailer)
@@ -107,7 +107,7 @@ Controller specs need to know what controller is being specified. You can
 indicate this by passing the controller to describe():
 
   describe MyController do
-    
+
 or by declaring the controller's name
 
   describe &quot;a MyController&quot; do
@@ -121,7 +121,7 @@ MESSAGE
         end
 
         attr_reader :response, :request, :controller
-        
+
         def integrate_views?
           @integrate_views || self.class.integrate_views?
         end
@@ -143,7 +143,7 @@ MESSAGE
             end
           end
         end
-        
+
       protected
 
         def _assigns_hash_proxy
@@ -151,27 +151,33 @@ MESSAGE
         end
 
       private
-        
+
         module TemplateIsolationExtensions
           def file_exists?(ignore); true; end
-          
+
           def render_file(*args)
             @first_render ||= args[0] unless args[0] =~ /^layouts/
           end
-          
+
           # Rails 2.2
           def _pick_template(*args)
             @_first_render ||= args[0] unless args[0] =~ /^layouts/
             PickedTemplate.new
           end
-          
+
           def __action_exists?(params)
             controller.respond_to? params[:action]
           end
-          
+
+          def __template_exists?(args)
+            self.view_paths.respond_to?(:find_template) ?
+              self.view_paths.find_template(args[0][:file], template_format) :
+              false
+          end
+
           def render(*args)
             if ::Rails::VERSION::STRING &gt;= &quot;2.1&quot;
-              return super unless __action_exists?(params) 
+              return super unless __action_exists?(params) || __template_exists?(args)
             end
             if file = args.last[:file].instance_eval{@template_path}
               record_render :file =&gt; file
@@ -183,23 +189,24 @@ MESSAGE
               super
             end
           end
-        
+
         private
-        
+
           def record_render(opts)
-            (@_rendered[:template] ||= opts[:file]) if opts[:file]
-            (@_rendered[:partials][opts[:partial]] += 1) if opts[:partial]
+            return unless @_rendered
+            @_rendered[:template] ||= opts[:file] if opts[:file]
+            @_rendered[:partials][opts[:partial]] += 1 if opts[:partial]
           end
-          
+
           # Returned by _pick_template when running controller examples in isolation mode.
-          class PickedTemplate 
+          class PickedTemplate
             # Do nothing when running controller examples in isolation mode.
             def render_template(*ignore_args); end
             # Do nothing when running controller examples in isolation mode.
             def render_partial(*ignore_args);  end
           end
         end
-        
+
         module ControllerInstanceMethods # :nodoc:
           include Spec::Rails::Example::RenderObserver
 
@@ -230,7 +237,7 @@ MESSAGE
               end
             end
           end
-          
+
           # Rails 2.3
           def default_template(action_name = self.action_name)
             if integrate_views?
@@ -243,7 +250,7 @@ MESSAGE
               end
             end
           end
-          
+
           def response(&amp;block)
             # NOTE - we're setting @update for the assert_select_spec - kinda weird, huh?
             @update = block
@@ -255,7 +262,7 @@ MESSAGE
           end
 
         private
-        
+
           def integrate_views?
             @integrate_views
           end
@@ -263,15 +270,15 @@ MESSAGE
           def matching_message_expectation_exists(options)
             render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
           end
-        
+
           def matching_stub_exists(options)
             render_proxy.__send__(:__mock_proxy).__send__(:find_matching_method_stub, :render, options)
           end
-        
+
         end
 
         Spec::Example::ExampleGroupFactory.register(:controller, self)
-        
+
       end
     end
   end</diff>
      <filename>lib/spec/rails/example/controller_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1 @@
+&lt;%- raise &quot;THIS TEMPLATE SHOULD NOT BE RENDERED&quot; -%&gt;
\ No newline at end of file</diff>
      <filename>spec/resources/views/controller_spec/non_existent_action_with_existent_template.html.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ca6054118c25f29084a214a443e31996689d26df</id>
    </parent>
  </parents>
  <author>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </author>
  <url>http://github.com/dchelimsky/rspec-rails/commit/85e264e2049accf4e5fd3b22cf38eca2960467c2</url>
  <id>85e264e2049accf4e5fd3b22cf38eca2960467c2</id>
  <committed-date>2009-10-21T07:23:01-07:00</committed-date>
  <authored-date>2009-10-21T07:22:24-07:00</authored-date>
  <message>record render instead of rendering if the template exists

[#902 state:resolved milestone:'Next Release']</message>
  <tree>4797ccd3c04c26adc419bd21519f531e75e854d2</tree>
  <committer>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </committer>
</commit>
