Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod missing error when using cucumber (with rails, webrat, and mongomapper)
    primarykey
    data
    text
    <p>I'm writing a few basic step instructions in Cucumber, and can't figure out why it's throwing up a "method missing" error. Here's the precise error:</p> <pre><code>undefined method `question' for nil:NilClass (ActionView::Template::Error) </code></pre> <p>The root of this error is this line from my index.html.erb page:</p> <pre><code>&lt;p id="question"&gt;&lt;%= @question.question %&gt;&lt;/p&gt; </code></pre> <p>So it looks like the test thinks that @question is nil. I'm not sure why it thinks this. What should I change in my step instructions? Here they are:</p> <pre><code>Given /^a question$/ do @question = Question.create!(:question =&gt; "here's my question..", :answer =&gt; "right_answer", :num =&gt; "1") end When /^I answer the question$/ do visit root_path fill_in "Answer", :with =&gt; "Wrong answer" click_button "Submit answer" end </code></pre> <p>The first step instruction passes, but the second does not. </p> <hr> <p>EDIT: Here's my entire index.html.erb page, in case it's useful:</p> <pre><code>&lt;% title "Questions" %&gt; &lt;p id="question"&gt;&lt;%= @question.question %&gt;&lt;/p&gt; &lt;%= form_for @user_answer do |f| %&gt; &lt;div&gt;&lt;%= f.label :answer %&gt;&lt;/div&gt; &lt;div&gt;&lt;%= f.text_field :answer %&gt;&lt;/div&gt; &lt;div id="sign_up_button"&gt;&lt;%= f.submit "Submit answer" %&gt;&lt;/div&gt; &lt;% end %&gt; &lt;p&gt;&lt;%= link_to "New Question", new_question_path %&gt;&lt;/p&gt; </code></pre> <hr> <p>EDIT: My Question model, in case it's useful:</p> <pre><code>class Question include MongoMapper::Document key :question, String, :required =&gt; true key :answer, String, :required =&gt; true key :num, String, :required =&gt; true </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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