Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:17:52+00:00 2026-05-28T14:17:52+00:00

I am running my tests for a rails application using test/unit and capybara. I

  • 0

I am running my tests for a rails application using test/unit and capybara. I am fairly new to rails, so I’m hoping that I’m missing something obvious. I have the following integration test to fill out a single field and submit a form. This works as expected and the test passes:

  test "create post with title only should add post" do
    assert_difference('Post.count') do
      visit '/posts/new'
      fill_in :title, :with => "Sample Post"
      click_button 'create Post'
    end

    assert current_path == post_path(Post.last)
    assert page.has_content?("Sample Post")
  end

I added a second test, that pretty much copies the previous test but also fills out a second field and checks for the additional input (this fails).

  test "create post with title and body should add post" do
    assert_difference('Post.count') do
    visit '/posts/new'
      fill_in :title, :with => "Testing"
      fill_in :body, :with => "This is a sample post"
      save_and_open_page
      click_button 'create Post'
    end
    save_and_open_page
    assert current_path == post_path(Post.last)
    assert page.has_content?("Testing")
    assert page.has_content?("This is a sample post")
end

When this failed, I added the call to:

save_and_open_page

and found that the form was being filled out with the title value from the previous test and no body value was supplied at all. The name of the test and the assertions match the second test, so this isn’t a case of mistaken identity. It seems that Capybara isn’t getting the updated values. I also have this code in my test_helper.rb file:

DatabaseCleaner.strategy = :truncation

module ActionController
  class IntegrationTest
    include Capybara::DSL

    self.use_transactional_fixtures = false

    teardown do
      DatabaseCleaner.clean
      Capybara.reset_sessions!
      Capybara.use_default_driver
    end
  end
end

I’m assuming this should clear out values in between tests. Since that clearly wasn’t happening, I also tried adding a call to Capybara.rest_sessions! at the end of the first test and that didn’t help.

Any advice or help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:17:53+00:00Added an answer on May 28, 2026 at 2:17 pm

    I figured it out. I was calling the fill in method with the symbol :title instead of a string for the field id. I needed to be using ‘post_title’. I started that way, but was not prefixing the name with the model name so it wasn’t found and it started working when I changed to the symbol that I was using in my erb code.

    So use:

    fill_in 'post_title', :with => "whatever"
    

    instead of

    fill_in :title, :with => "whatever"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running unit and functional tests using rake, on a rails application, I notice
I have a set of Test::Unit tests for a Rails application. It was developed
When running tests in Ruby's unit::test framework, is there a really easy way to
We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests
We have some unit tests running against a SQL server 2000 database using the
I was investigating using the Rake build tool to automate running unit tests. I
I'm running a rails application on EC2, and I'm using mongoHQ as DBMS. I've
I have a rails application on RubyMine. While running tests on terminal(Mac OS X
I'm running tests using the TestDriven.NET VS add-in, and the class library I'm testing
When running performance tests file system cache hit or miss can significantly influence test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.