Note that there are some explanatory texts on larger screens.

plurals
  1. POnested feature in capybara 2.0+
    primarykey
    data
    text
    <p>i want to do something like this:</p> <pre><code>feature "sign-up" do before {visit signup_path} let(:submit) {"Create my account"} feature "with invalid information" do scenario "should not create a user" do expect {click_button submit}.not_to change(User, :count) end end feature "with valid information" do scenario "should create a user" do fill_in "Name", with: "test name" fill_in "Email", with: "test@test.com" fill_in "Password", with: "password" fill_in "Confirmation", with: "password" expect {click_button submit}.to change(User, :count).by(1) end end end </code></pre> <p>but when i run rspec i get</p> <pre><code>in `block in &lt;top (required)&gt;': undefined method `feature' for #&lt;Class:0x000000039e0018&gt; (NoMethodError) </code></pre> <p>if i change it a bit to look like this it works:</p> <pre><code> feature "with invalid information" do before {visit signup_path} let(:submit) {"Create my account"} scenario "should not create a user" do expect {click_button submit}.not_to change(User, :count) end end feature "with valid information" do before {visit signup_path} let(:submit) {"Create my account"} scenario "should create a user" do fill_in "Name", with: "test name" fill_in "Email", with: "test@test.com" fill_in "Password", with: "nirnir" fill_in "Confirmation", with: "nirnir" expect {click_button submit}.to change(User, :count).by(1) end end </code></pre> <p>EDIT:</p> <p>plus, the following code works(describe nested inside feature) - but is it wrong in any way?</p> <pre><code>feature "sign-up" do background {visit signup_path} given(:submit) {"Create my account"} scenario "with invalid information" do expect {click_button submit}.not_to change(User, :count) end describe "with valid information" do background do fill_in "Name", with: "test name" fill_in "Email", with: "test@test.com" fill_in "Password", with: "password" fill_in "Confirmation", with: "password" end scenario { expect {click_button submit}.to change(User, :count).by(1) } scenario "after submission" do click_button submit page.html.should have_content("Registration successful") end end end </code></pre>
    singulars
    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