Why not use shared ActiveRecord connections for Rspec + Selenium?

Actually there are issues with it. If you use the gem mysql2, for example, you’ll start seeing some errors like: Mysql2::Error This connection is still waiting for a result Please use this instead. It was written by Mike Perham, all credits to him. class ActiveRecord::Base mattr_accessor :shared_connection @@shared_connection = nil def self.connection @@shared_connection || ConnectionPool::Wrapper.new(:size … Read more

“undefined method `env’ for nil:NilClass” in ‘setup_controller_for_warden’ error when testing Devise using Rspec

In Rails 5 you must include Devise::Test::IntegrationHelpers instead Devise::Test::ControllerHelpers: # rails_helper.rb config.include Devise::Test::IntegrationHelpers, type: :feature See more: https://github.com/plataformatec/devise/issues/3913#issuecomment https://github.com/plataformatec/devise/pull/4071

Cucumber vs Capybara

Capybara is a tool that interacts with a website the way a human would (like visiting a url, clicking a link, typing text into a form and submitting it). It is used to emulate a user’s flow through a website. With Capybara you can write something like this: describe “the signup process”, :type => :feature … Read more

Multiple Capybara wait times?

You can use using_wait_time(seconds) method like: using_wait_time 3 do expect(page).to have_text ‘Lorem ipsum’ end or :wait option (that appeared in Capybara 2.1). Note that :wait option was supported only by find method in Capybara 2.1. Support for :wait option in matchers (i.e. has_x? and have_x methods) has been added in Capybara 2.2: expect(page).to have_text(‘Lorem ipsum’, … Read more

Capybara with :js => true causes test to fail

I’ve read the Capybara readme at https://github.com/jnicklas/capybara and it solved my issue. Transactional fixtures only work in the default Rack::Test driver, but not for other drivers like Selenium. Cucumber takes care of this automatically, but with Test::Unit or RSpec, you may have to use the database_cleaner gem. See this explanation (and code for solution 2 … Read more

How to emulate mouse hover with Capybara

Capybara provides Element#hover method from version 2.1: find(‘.some_class’).hover This method is implemented in Capybara::Selenium::Driver in almost the same way as in @AlexD’s answer. Note that to use #hover in Selenium it’s usually better to turn native events on: Capybara.register_driver :selenium do |app| profile = Selenium::WebDriver::Firefox::Profile.new profile.native_events = true Capybara::Selenium::Driver.new(app, :browser => :firefox, profile: profile) end

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)