Note that there are some explanatory texts on larger screens.

plurals
  1. POCucumber: rails dynamic find not working in paths.rb
    text
    copied!<p>I am working on rails with rspec, rspec-rails, cucumber and webrat. I am trying to learn BDD and testing in general. I have a cucumber scenario like this:</p> <pre><code> Scenario: Questions List Given quiz titled "Pearl Jam" has questions named "Corduroy, Dissident" When I go to the experiment page for quiz titled "Pearl Jam" Then I should see "Corduroy" And I should see "Dissident" </code></pre> <p>I have alrady added step 1, where I create and save a quiz correctly (I tested through puts). Now I am working on step 2. I am adding a new path in paths.rb</p> <pre><code>when /^the experiment page for quiz titled "(.*)"$/i new_quiz_experiment_path(Quiz.find_by_title($1)) </code></pre> <p>For some reason <code>find_by_title</code> does not work. I get this error message:</p> <pre><code>new_quiz_experiment_url failed to generate from {:quiz_id=&gt;nil, :action=&gt;"new", :controller=&gt;"experiments"}, expected: {:action=&gt;"new", :controller=&gt;"experiments"}, diff: {:quiz_id=&gt;nil} (ActionController::RoutingError) </code></pre> <p>I am sure the record is there, and correctly saved; if I insert</p> <pre><code>puts Quiz.find(1).title </code></pre> <p>I get "Pearl Jam". Looks like <code>find_by</code> is not working, which is quite weird since the cucumber generated file contains this example:</p> <pre><code> # when /^(.*)'s profile page$/i # user_profile_path(User.find_by_login($1)) </code></pre> <p>I also tried a simpler find first with conditions, it doesn't work either.</p> <p>Any idea?</p> <p>Thanks in advance,<br> Davide</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