What i have figured is that If i use factorygirl with js: true, the database becomes locked.
So i had to write this long scenario
scenario "and see the question on the screen below" ,js: true do
sign_in_admin(admin)
create_event
code = page.find('div span#code').text
click_link "Logout"
fill_in "subscriber_code",with: code
click_button "Join Event"
fill_in "body",with: "Hi how are you?"
click_button "Ask"
click_link "Logout"
sign_in_admin(admin)
click_button "approve"
click_link "Logout"
fill_in "subscriber_code",with: code
click_button "Join Event"
page.should have_content "Hi how are you?"
click_button "up"
click_link "Logout"
fill_in "subscriber_code",with: code
click_button "Join Event"
votes = page.find('#votes').text
expect(votes).to eq("1")
click_button "up"
expect(page).to have_button "down"
click_button "down"
click_link "Logout"
fill_in "subscriber_code",with: code
click_button "Join Event"
votes = page.find('#votes').text
expect(votes).to eq("1")
end
This is my databse_cleaner
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.use_transactional_fixtures = false
config.include FactoryGirl::Syntax::Methods
config.before :each do
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
So how can I break the above scenario using FactoryGirl like question = create(:question) which currently is locking the database and also is giving RecordNotFound error.