The gist of what I'm trying to test is loading a page, updating the state of an object in the database, then reloading the page to see that reference to the object is no longer there. Something along the lines of this:
before do
<some setup stuff that requires js: true)
<ObjectClass>.first.update(current_state: <new state>)
visit user_path(user)
end
it "should remove the reference to the object", js: true do
should_not have_content "<Text about the object>"
end
In case it is relevant:
config.use_transactional_fixtures = false and the use of database_cleaner
The issue I'm running into is that often the update to the object doesn't take. If I then run the test again, with no changes anywhere, it may fail again or it may pass. I have confirmed that the state is not changing by printing it out at the end of the before, after the visit. No database errors or the like are being shown.
The object is initially being created in one of two ways...in some tests using FactoryGirl, in others using a form within the site (so via the controller). Both types of tests are displaying this behavior.
Thoughts as to what might be causing this intermittent behavior?
Additional note:
Here's the contents of spec/support/database_cleaner.rb, which was likely some default version that I'm inspecting more closely right now:
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, :js => true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end