Note that there are some explanatory texts on larger screens.

plurals
  1. POview test using rspec & factory girl error: No route matches
    text
    copied!<p>I am fairly new to Ruby &amp; Rails; have not done much programming; but have a tech background. </p> <p>I've built a very small amount of functionality mostly based on Railscasts and want to go with TDD, and am going back and trying to build some simple tests before moving forward.</p> <p>I'm stuck on a test of a view and can not find anything similar enough to figure out how to resolve this. I've looked thru the Railscasts, The RSpec book, etc., and have done a lot of searches.</p> <p>The desired functionality seems to work fine, but the test fails.</p> <p>Any help or direction is appreciated.</p> <p><strong>Error:</strong></p> <pre><code> Failure/Error: render ActionView::Template::Error: No route matches {:action=&gt;"show", :controller=&gt;"email_verifies", :id=&gt;nil} # ./app/views/email_verifies/edit.html.haml:3:in `_app_views_email_verifies_edit_html_haml__3756516833416545914_70345184965780' # ./spec/views/email_verifies/edit.html.haml_spec.rb:6:in `block (2 levels) in &lt;top (required)&gt;' </code></pre> <p><strong>Code:</strong></p> <p>app/views/email_verifies/edit.html.haml</p> <pre><code>%h1 Verify Email Address = form_for @user, :url =&gt; email_verify_path(params[:id]) do |f| .actions = f.submit "Verify Email Address" </code></pre> <p>spec/views/email_verifies/edit.html.haml_spec.rb</p> <pre><code>require 'spec_helper' describe "email_verifies/edit.html.haml" do let(:user) { FactoryGirl.create(:user, :email_verify_token =&gt; "anything") } it "displays the text on the rendered page" do render rendered.should have_content("Verify Email Address") end end </code></pre> <p>spec/factories/factories.rb</p> <pre><code>FactoryGirl.define do factory :user do sequence :email do |n| "foo#{n}@example.com" end password "secret" end end </code></pre> <p>part of app/controllers/email_verifies_controller.rb (there is no 'show' action in this controller)</p> <pre><code>def edit @user = User.find_by_email_verify_token(params[:id]) unless @user redirect_to signup_path, :alert =&gt; "This email verification has expired. Please sign up again." end end </code></pre> <p><strong>Some of the routes:</strong></p> <pre><code>edit_email_verify GET /email_verifies/:id/edit(.:format) email_verifies#edit email_verify GET /email_verifies/:id(.:format) email_verifies#show email_verifies GET /email_verifies(.:format) email_verifies#index edit_email_verify GET /email_verifies/:id/edit(.:format) email_verifies#edit email_verify GET /email_verifies/:id(.:format) email_verifies#show PUT /email_verifies/:id(.:format) email_verifies#update </code></pre> <p><strong>Versions:</strong> </p> <p>ruby 1.9.3p362<br> rails (3.2.13)<br> factory_girl (4.2.0)<br> factory_girl_rails (4.2.1)<br> rspec (2.13.0)<br> rspec-core (2.13.1)<br> rspec-expectations (2.13.0)<br> rspec-mocks (2.13.1)<br> rspec-rails (2.13.2) </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