Here is the gems used for our spec in Rails 4.2 engine.
s.add_development_dependency "sqlite3"
s.add_development_dependency "rspec-rails", ">= 3.2.0"
s.add_development_dependency "factory_girl_rails", '~>4.5'
s.add_development_dependency 'capybara'
s.add_development_dependency 'launchy'
Here is a integration spec for create an order record:
visit multi_item_orderx.orders_path(customer_id: @kustomer.id)
click_link 'New Cob Order'
expect(page).to have_content('New Order')
fill_in 'order_order_date', :with => 10.days.ago
fill_in 'order_order_total', :with => 50
fill_in 'order_cob_info_bonding_product', :with => 'a bonding prod'
fill_in 'order_cob_info_name', :with => 'storage'
fill_in 'order_cob_info_qty', :with => 10
fill_in 'order_cob_info_unit_price', :with => 10
click_button 'Save'
expect(CobOrderx::CobInfo.count).to eq(1)
The problem is that CobOrderx::CobInfo.count returns 0
instead of 1
. In debug, @order
is saved successfully and CobOrderx::CobInfo.count
returns 1
.
But back in spec:
expect(CobOrderx::CobInfo.count).to eq(1)
returns false
since .count
is 0
. We tried to set the following in rails_helper
and it did not work:
config.use_transactional_fixtures = false
The problem seems to be with the spec (capybara) and we are not sure why. What could cause the db record lost in integration test?