3

I'm having an issue with JS request specs - basic visiting of a 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's definitely in the DB! visit edit_doc_path(doc) end 

Result: "ActiveRecord::RecordNotFound - Couldn't find doc with id=1"

The odd thing is it works with standard request spec. I tried both webkit and selenium drivers. 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 versioning for capybara, rspec, etc. test libraries.

Any input much appreciated! Thanks!

1
  • What happens if you remove js:true? Commented May 21, 2012 at 20:32

1 Answer 1

-1

Seems like you have same problem as this: Capybara with :js => true causes test to fail

Try setting DatabaseCleaner strategy to :truncation and see if it works

config.before(:suite) do DatabaseCleaner.strategy = :truncation end 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.