Problem with Capybara request parameters with JS - cannot find model

I have a problem with JS query specifications - the main visit to the model edit page:

it "can edit a doc", :js => true do
  doc = FactoryGirl.create(:doc) # tried with Doc.create as well
  puts Doc.find(doc.id) # 1 <- so it definitely in the DB!
  visit edit_doc_path(doc) 
end

Result: "ActiveRecord :: RecordNotFound - Could not find doc with id = 1"

It is strange that this works with the standard query specification. I tried both webkit drivers and selenium. My spec_helper looks like this (should be pretty standard):

RSpec.configure do |config|
  config.use_transactional_fixtures = false

  Capybara.javascript_driver = :webkit

  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

  config.before(:each, :type => :request) do
    Capybara.reset_sessions!
  end
end

Rails 3.1.4, no versions for test libraries capybara, rspec, etc.

Any input is much appreciated! Thank!

+3
source share
1 answer

It looks like you have the same problem: Capybara with: js => true test reasons don't work

DatabaseCleaner : ,

config.before(:suite) do
  DatabaseCleaner.strategy = :truncation
end
-1

All Articles