Note that there are some explanatory texts on larger screens.

plurals
  1. PORspec/Capybara test cases are not working for multiple 'it' blocks
    primarykey
    data
    text
    <p>I am writing some integration test cases for an existing application. My test works fine if there is only one 'it' block. However, If I add more than one 'it' block it throws an error. Below is my code that works:</p> <pre><code>require 'spec_helper' describe 'Group' do before do visit 'http://groups.caremonkey.com/users/sign_in' fill_in "Email", :with =&gt; "email@example.com" fill_in "Password", :with =&gt; "password" click_button "Login" page.should have_link('Account') end it 'Should check all the links and functionality of groups' do #add new subgroup with valid data should save a new group find("#group-squares").click_link("Add") fill_in "Group Name", :with =&gt; "Melbourne futsal" click_on("Save") page.should_not have_content("can't be blank") page.execute_script("parent.$.fancybox.close();") page.should have_link('Account') #test edit group: should be able to update group info provided valid data are given first(".actual img").click page.should have_content("Group") page.should have_link("Cancel") fill_in "Group name", :with =&gt; "Futsal club" page.execute_script("$('#sub-group-color-options').find('.color23').click()") click_button "Save" click_on("Cancel") page.should have_link('Account') end end </code></pre> <p>It works perfectly fine when I put all the '<b>it</b>' block together in a single 'it' block. But when I split them in different 'it' block, it stops working. For example if I split this ("test edit group: should be able to update group info provided valid data are given") test case into separate 'it' block as follows</p> <pre><code> require 'spec_helper' describe 'Group' do before do visit 'http://groups.caremonkey.com/users/sign_in' fill_in "Email", :with =&gt; "email@example.com" fill_in "Password", :with =&gt; "password" click_button "Login" page.should have_link('Account') end it 'add new subgroup with valid data should save a new group' do find("#group-squares").click_link("Add") fill_in "Group Name", :with =&gt; "Melbourne futsal" click_on("Save") page.should_not have_content("can't be blank") page.execute_script("parent.$.fancybox.close();") page.should have_link('Account') end it 'should be able to update group info provided valid data are given' do first(".actual img").click page.should have_content("Group") page.should have_link("Cancel") fill_in "Group name", :with =&gt; "Futsal club" page.execute_script("$('#sub-group-color-options').find('.color23').click()") click_button "Save" click_on("Cancel") page.should have_link('Account') end end </code></pre> <p>then rspec fails, it passes the first test, however second test gets failed throwing following error. </p> <pre><code>Failure/Error: visit 'http://groups.caremonkey.com/users/sign_in' ActionController::RoutingError: No route matches [GET] "/users/sign_in" </code></pre> <p>One more thing, I have to test all the features in remote(url: <a href="http://groups.caremonkey.com/" rel="nofollow">http://groups.caremonkey.com/</a>). Because, I am writing integration tests for an existing application. In addition, I need to login to the system before I test rest of the features of my application. Thanks in advance for your help.</p>
    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.
 

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