Note that there are some explanatory texts on larger screens.

plurals
  1. POCapybara and Rails have_content failing in spec to test to see if a messages partial appears
    primarykey
    data
    text
    <p>I have a request spec which passes up until the point where I need to check to see if content is present on the page, which I am using <code>page.should have_content</code> to do. The content is actually a message which appears on successful form submission, which is rendered from a messages partial. The test fails even though If I test through the browser, functionality works as expected and the content appears as it should. I'm also using FactoryGirl to generate the users to use for the form submission.</p> <p>Here's the error I get after running the spec with the --format d option:</p> <pre><code>UserSignup shows a thank you message on successful form submission (FAILED - 1) Failures: 1) UserSignup shows a thank you message on successful form submission Failure/Error: page.should have_content("Thank you. You will be notified of our launch at #{user.email}.") expected #has_content?("Thank you. You will be notified of our launch at quinn.purdy@casperzboncak.org.") to return true, got false # ./spec/requests/user_signup_spec.rb:21:in `block (2 levels) in &lt;top (required)&gt;' </code></pre> <p>user_signup_spec.rb:</p> <pre><code>require 'spec_helper' describe "UserSignup" do it "shows a thank you message on successful form submission" do user = FactoryGirl.create(:user) visit sign_up_path fill_in "user_fullname", with: user.fullname fill_in "user_email", with: user.email click_button "Sign up" current_path.should eq(sign_up_path) page.should have_content("Thank you. You will be notified of our launch at #{user.email}.") end end </code></pre> <p>users_controller.rb:</p> <pre><code>class UsersController &lt; ApplicationController def new @user = User.new end def create @user = User.new(secure_params) if @user.valid? @user.subscribe flash[:notice] = "Thank you. You will be notified of our launch at #{@user.email}." redirect_to sign_up_path else render :new end end private def secure_params params.require(:user).permit(:fullname, :email) end end </code></pre> <p>I'm wondering if it could be because I render the messages partial from the application layout, but when it gets outputted in the users view, the message appears inside the <code>body</code> of the source, but outside the <code>main</code> class.</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