I have my Rails-App set up with Capybara. Tests are working fine but I'm getting this error:
2019-05-03 14:51:58 WARN Selenium [DEPRECATION]
Selenium::WebDriver::Chrome#driver_path= is deprecated. Use
Selenium::WebDriver::Chrome::Service#driver_path= instead.
Gemfile
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
test_helper.rb
(with or without the disabled lines makes no difference)
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'capybara/rspec'
require 'rspec/rails'
require 'capybara/rails'
RSpec.configure do |config|
# Capybara.register_driver :chrome do |app|
# Capybara::Selenium::Driver.new app, browser: :chrome,
# options: Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu])
# end
# Capybara.javascript_driver = :chrome
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
Kernel.srand config.seed
end
Any ideas?
It is not an error,it is a deprecation warning.
The gem chromedriver-helper is deprecated
NOTICE: This gem is out of support as of 2019-03-31 Please use
https://github.com/titusfortner/webdrivers instead. See
https://github.com/flavorjones/chromedriver-helper/issues/83 for
details.
In you gemfile:
group :test do
gem 'webdrivers', '~> 3.0'
end
group :development, :test do
gem 'capybara'
end
I'll suggest you to move capybara in the development and test's group, and also update it, if is possible.
this worked for me. Since the gem is deprecated, I just uninstalled the gem
gem uninstall chromedriver-helper
then remove it from your gem file and run:
bundle update
after that, add the webdriver gem in-place, and bundle install
gem 'webdrivers', '~> 4.0'
bundle install
the warnings should be gone
I had this concern when working on a Rails 6 application in Ubuntu 20.04.
The issue is that the chrome-helper gem is deprecated. Its last version was 2.1.1 in March 24, 2019.
Here's how I fixed it:
Simply replace the chrome-helper gem with the webdrivers gem in your Gemfile:
So instead of this:
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
You will have this:
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'webdrivers'
end
Then install the gem using:
bundle install
This will update your Gemfile.lock will the webdrivers gem and remove the chrome-helper gem from it as well.
That's all.
I hope this helps
Related
I have my Rails-App set up with Capybara. Tests are working fine but I'm getting this error:
2019-05-03 14:51:58 WARN Selenium [DEPRECATION]
Selenium::WebDriver::Chrome#driver_path= is deprecated. Use
Selenium::WebDriver::Chrome::Service#driver_path= instead.
Gemfile
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
test_helper.rb
(with or without the disabled lines makes no difference)
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'capybara/rspec'
require 'rspec/rails'
require 'capybara/rails'
RSpec.configure do |config|
# Capybara.register_driver :chrome do |app|
# Capybara::Selenium::Driver.new app, browser: :chrome,
# options: Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu])
# end
# Capybara.javascript_driver = :chrome
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
Kernel.srand config.seed
end
Any ideas?
It is not an error,it is a deprecation warning.
The gem chromedriver-helper is deprecated
NOTICE: This gem is out of support as of 2019-03-31 Please use
https://github.com/titusfortner/webdrivers instead. See
https://github.com/flavorjones/chromedriver-helper/issues/83 for
details.
In you gemfile:
group :test do
gem 'webdrivers', '~> 3.0'
end
group :development, :test do
gem 'capybara'
end
I'll suggest you to move capybara in the development and test's group, and also update it, if is possible.
this worked for me. Since the gem is deprecated, I just uninstalled the gem
gem uninstall chromedriver-helper
then remove it from your gem file and run:
bundle update
after that, add the webdriver gem in-place, and bundle install
gem 'webdrivers', '~> 4.0'
bundle install
the warnings should be gone
I had this concern when working on a Rails 6 application in Ubuntu 20.04.
The issue is that the chrome-helper gem is deprecated. Its last version was 2.1.1 in March 24, 2019.
Here's how I fixed it:
Simply replace the chrome-helper gem with the webdrivers gem in your Gemfile:
So instead of this:
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
You will have this:
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'webdrivers'
end
Then install the gem using:
bundle install
This will update your Gemfile.lock will the webdrivers gem and remove the chrome-helper gem from it as well.
That's all.
I hope this helps
Please forgive any shortcomings in this (my first-ever) post on StackOverflow. I'm brand new to Ruby on Rails. I'm following the Rails Tutorial. I have spent many unsuccessful hours consulting other threads discussing the same Name Error that I'm raising in this question.
Any attempt of mine to run an rspec test like so: $bundle exec rspec spec/models/user_spec.rb
throws the now infamous error: `': uninitialized constant Rails (NameError)
Let me know if there's any more information I should provide you in order to get the ball rolling.
Here's my gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
# The following optional lines are part of the advanced setup.
# gem 'guard-rspec', '2.5.0'
# gem 'spork-rails', '4.0.0'
# gem 'guard-spork', '1.5.0'
# gem 'childprocess', '0.3.6'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.0'
gem 'cucumber-rails', '1.4.0', :require => false
gem 'database_cleaner', github: 'bmabey/database_cleaner'
# Uncomment these lines on Linux.
# gem 'libnotify', '0.8.0'
# Uncomment these lines on Windows.
# gem 'rb-notifu', '0.0.4'
# gem 'win32console', '1.3.2'
# gem 'wdm', '0.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Here is my spec/models/user_spec.rb file:
require 'spec_helper'
describe User do
pending "add some examples to (or delete) #{__FILE__}"
end
Here is my app/models/user.rb file:
class User < ActiveRecord::Base
end
Here is my spec_helper.rb file:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
require 'test/unit'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.include Capybara::DSL
end
I have definitely run bundle install. I can also confirm that I've already created the database and run the migration (db/test.sqlite3 already exists)
In your spec_helper.rb, you have the following line twice:
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Delete the first instance (the one on line 2). This is what is causing the error.
Having this line before require 'rspec/rails' will cause problems because we don't know what Rails is, and so we cannot call the root method.
The second instance (on line 13) is fine because this is after require 'rspec/rails'.
Remove redundant require 'spec_helper' line from your spec_helper.rb file.
I am trying to run test features."bundle exec cucumber features" starts failing abnormally(during login itself),it fails to recognize an existing user. while it works fine if i run individual feature files. What am i doing wrong?
Gem File:
group :test do
gem 'ruby-prof'
gem 'cucumber-rails', :require => false
gem 'cucumber'
gem 'spork'
gem 'launchy'
gem 'capybara'
gem 'selenium-webdriver'
gem 'selenium-client'
gem 'database_cleaner'
gem 'email_spec', :branch=>'rails3'
end
In env.rb
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Trying to resurrect an old project by upgrading gems. Ran into an issue where RSpec hangs on startup with the '--drb' option.
By itself, 'rspec spec' works fine. But start 'spork' in another terminal and then 'rspec --drb spec' spins up CPU to ~40% and just sits.
Using Rails 3.2.13, Ruby 1.9.3-p392, RSpec 2.13.1 and spork-rails 3.2.1, which depends on Spork 1.0.0rc3.
Gemfile
source 'http://rubygems.org'
gem 'rails', '~> 3.2.13'
gem 'devise', '~> 2.2.0'
gem 'event-calendar', :require => 'event_calendar'
gem 'has_scope'
gem 'high_voltage'
gem 'inherited_resources'
gem 'jquery-rails'
gem 'kaminari'
gem 'ransack'
gem 'simple_form'
gem 'validates_timeliness'
# deployment process management
gem 'foreman'
gem 'thin'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '< 2.0'
gem 'bootstrap-sass', '~> 2.3.1'
end
group :production do
gem 'pg'
end
group :development, :test do
gem 'factory_girl_rails', '~> 4.2.0'
gem 'rspec-rails', '~> 2.13.1'
gem 'spork-rails'
gem 'sqlite3'
end
group :test do
gem 'capybara'
gem 'growl'
gem 'launchy'
gem 'ruby-prof'
gem 'test-unit'
end
spec/spec_helper.rb
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Prevent Devise from loading the User model super early with it's routes
# see: https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujitsu
require "rails/application"
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Since I have included Test::Unit for perfomance tests, disable auto-run
Test::Unit::AutoRunner.need_auto_run = false if defined?(Test::Unit::AutoRunner)
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
I'm not getting any error messages or feedback on the console, so I don't even know where to start looking for problems. Any suggestions?
Upgrading ruby-build via brew update ruby-build picked up a new version dated 2013-05-01. After the update, I trashed and reinstalled all my Rubies, and the problem seems to have resolved itself.
I don't know what specifically addressed the issue, but here are some notes and a relevant commit: https://github.com/sstephenson/ruby-build/commit/9f8d53365aef52c940095f583cdc82f02caba90f
I really like Miniskirt and Minitest but I am having issues loading the factories.rb file on each run using spork server. It goes:
cannot load such file -- factories (LoadError)
My factories.rb file is located in the /test directory along with my test_helper.rb.
Any tips would be appreciated.
require 'rubygems'
require 'spork'
Spork.prefork do
...
require 'factories'
end
It took me a little trial and error to get everything to work, but I fixed it by switching to spork-minitest and using the master branch of guard-minitest. Here's my test suite:
group :test, :development do
gem 'capybara'
gem 'database_cleaner'
gem 'awesome_print'
gem 'turn'
gem 'guard'
gem 'guard-spork'
gem 'guard-minitest', github: 'guard/guard-minitest'
gem 'guard-livereload'
gem 'terminal-notifier-guard'
gem 'capybara_minitest_spec'
gem 'rb-fsevent', '~> 0.9.1'
gem "spork-minitest", git: "https://github.com/semaperepelitsa/spork-minitest.git"
gem 'miniskirt'
gem 'minitest-spec-rails'
end
Thanks for the help anyway.