← Back to Upcase

Capybara and javascript issue


(rafik bennacer) #1

i am wondering if you need to do something to the database when you use js=>true in Capybara. i am trying to test my search feature which is using a JS feature and whenever the webdriver selenium opens the browser for the test ,it opens it with an empty database.

require 'spec_helper'
feature "Searching  myths"  do
	before(:each) {
		FactoryGirl.create(:myth1)
		FactoryGirl.create(:myth2) 
	}
 
	scenario 'search a keyword', :js => true  do
		visit root_path
 
		# puts Myth.all.inspect
		fill_in :query, :with=>"coal"
		expect(page).to have_css("div.results")
		find "div.results" do |results|
		   expect(result).to have_selector "article", :count=>2
		end 
	end
end

(rafik bennacer) #2

SOLVED
i was using config.use_transactional_fixtures = true in your spec_helper.rb. It doesn’t work with Capybara javascript specs because the server and the browser client run on separate threads.