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 7762227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:20:36+00:00 2026-06-01T14:20:36+00:00

I cannot get request specs working when using Javascript. My specs pass if I

  • 0

I cannot get request specs working when using Javascript.
My specs pass if I run them without Javascript (the page is built to work with or without JS).

Specifically, the specs fail when I do assertions like Post.should have(1).record.
Capybara just doesn’t pick up the records from the DB, and the database is not cleaned between runs.

I’ve tried using DatabaseCleaner with transactional fixtures disabled – the common approach to this, I guess. No dice.

I’ve also tried (and, would ideally prefer) running without DatabaseCleaner, using transactional fixtures and forcing AR to share the same connection between threads (a patch described by José Valim). Again, no dice.

Additionally, I’ve also tried switching between Capybara-webkit and Selenium – the issue persists.

I’ve put up a sample app with just a basic Post scaffold, that replicates the problem: https://github.com/cabgfx/js-specs
There’s a spec_helper.rb with transactional fixtures and AR shared connection, and a spec_helper_database_cleaner.rb for the other scenario.

I normally use Spork, but I’ve disabled it in both spec_helper.rb files, just to eliminate a potential point of failure (in both apps; the “real” one and the sample app).

I develop locally using Pow on a Macbook Air, running OS X 10.7.3 with MRI 1.9.3 thru RVM. (I also tried on 1.9.2).

Hope I’m making sense – any guidance/help/pointers are 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-06-01T14:20:38+00:00Added an answer on June 1, 2026 at 2:20 pm

    Matt – thanks a lot for taking time to assist me!
    I tried setting it up with your spec_helper, using Selenium as the javascript driver.

    The spec still failed – but I could see the correct behavior being executed in Firefox…
    Then it dawned on me, that the problem might occur because of Capybara not waiting for AJAX requests to finish.

    I then reverted to my initial spec_helper (with Spork and no DatabaseCleaner), and simply used Capybara’s wait_until { page.has_content? "text I'm inserting with JS" }.

    I updated the sample app, and just added sleep 1 in the request spec, so you can see for yourself. It now works with and without Spork, and the AR monkey patch seems to work perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot get my SID working ... <?php session_start(); // Or maybe pass along
I cannot get Bindable LINQ to work with VB.NET for the life of me.
I cannot get the jQuery slideDown function to work on <table> elements. They just
I cannot get the example Python programs to run. When executing the Python command
I cannot get interception to work with Prism v2 (Oct 2009). I am trying
I'm trying to make an AJAX GET request, but I simply cannot get it
I am trying to get Oauth working with the Google API using Python. I
I want to make am HTTP GET request from my J2ME application using HttpConnection
It should be so simple but I cannot get it work. Json response is
I get the error: XPath syntax error at ... in {...get-request-parameter('query..}: Cannot find a

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.