Note that there are some explanatory texts on larger screens.

plurals
  1. PORspec stubing view for anonymous controller
    text
    copied!<p>I'm trying to test a method on the application controller that will be used as a before filter. To do this I have setup an anonymous controller in my test with the before filter applied to ensure that it functions correctly.</p> <p>The test currently looks like this:</p> <pre><code>describe ApplicationController do controller do before_filter :authenticated def index end end describe "user authenticated" do let(:session_id){"session_id"} let(:user){OpenStruct.new(:email =&gt; "pythonandchips@gmail.com", :name =&gt; "Colin Gemmell")} before do request.cookies[:session_id] = session_id UserSession.stub!(:find).with(session_id).and_return(user) get :index end it { should assign_to(:user){user} } end end </code></pre> <p>And the application controller is like this:</p> <pre><code>class ApplicationController &lt; ActionController::Base protect_from_forgery def authenticated @user = nil end end </code></pre> <p>My problem is when ever I run the test I'm getting the following error</p> <pre><code>1) ApplicationController user authenticated Failure/Error: get :index ActionView::MissingTemplate: Missing template stub_resources/index with {:handlers=&gt;[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=&gt;[:html], :locale=&gt;[:en, :en]} in view paths "#&lt;RSpec::Rails::ViewRendering::PathSetDelegatorResolver:0x984f310&gt;" </code></pre> <p>According to the docs the view is not <a href="http://rspec.info/rails/writing/controllers.html" rel="noreferrer">rendered when running controller tests</a> however this points to no stub existing for this action (which is understandable as the view doesn't exist)</p> <p>Anyone have a clue how to solve this problem or stub the view out.</p> <p>Cheers Colin G</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload