Skip to content

Instantly share code, notes, and snippets.

@jtrim
Created January 14, 2012 00:52
Show Gist options
  • Select an option

  • Save jtrim/1609642 to your computer and use it in GitHub Desktop.

Select an option

Save jtrim/1609642 to your computer and use it in GitHub Desktop.
it 'creates a participant after clicking `confirm' do
load_page
click_on '10:00 am'
# Not sure why the ActiveRecord connection is becoming
# stale...probably something to do with the way capybara runs tests
# with selenium.
#
# Symptom that led to the change:
# Running this in isolation without refreshing the connection would
# yield a passing test. Running it with errbody else caused it to
# fail. When I changed Participant.count to something like:
#
# ActiveRecord::Base.connection.execute('select count(*) from participants').first["count"].to_i
#
# ...the test passed when ran with all other tests, so this led me
# to believe the connection was becoming stale. Re-establishing the
# connection fixes the problem.
expect {
click_on 'Confirm'
}.to change { ActiveRecord::Base.establish_connection; Participant.count }.by(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment