Skip to content

Commit

Permalink
fix selenium specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrisoxide committed Jul 26, 2023
1 parent 1e8553d commit 31adcf5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ group :development, :test do
end

group :test do
gem 'webrick'
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
Expand Down
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ GEM
devise-i18n (1.11.0)
devise (>= 4.9.0)
diff-lcs (1.5.0)
dynamic_form (1.1.4)
dynamic_form (1.2.0)
email_reply_parser_ffcrm (0.5.0)
erubi (1.12.0)
execjs (2.8.1)
Expand Down Expand Up @@ -403,7 +403,7 @@ GEM
sprockets-rails
tilt
select2-rails (4.0.13)
selenium-webdriver (4.9.0)
selenium-webdriver (4.10.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -439,6 +439,7 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webrick (1.8.1)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
Expand Down Expand Up @@ -529,6 +530,7 @@ DEPENDENCIES
tzinfo-data
uglifier
webdrivers
webrick
will_paginate
zeus

Expand Down
12 changes: 2 additions & 10 deletions lib/fat_free_crm/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ def self.included(base)
end
end

def each_with_explicit_error
attribute_names.each do |attribute|
self[attribute].each do |error|
if error.start_with?('^')
yield :base, error[1..-1] # Drop the attribute.
else
yield attribute, error # This is default Rails3 behavior.
end
end
end
def each_with_explicit_error(&block)
@errors.each(&block)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/features/support/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

if ENV['BROWSER'] == 'chrome'
Capybara.register_driver :selenium do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w[no-sandbox headless disable-gpu] })
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
options = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w[no-sandbox headless disable-gpu] })
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
else
# For local testing in an environment with a display or remote X server configured
# such as WSL2, use NO_HEADLESS=1 bundle exec rspec spec/features
#
# For modern firefox, use MARIONETTE=1 bundle exec rspec spec/features
# NB the marionette setting is deprecated. For modern firefox, install the geckodriver.
Capybara.register_driver :selenium do |app|
options = Selenium::WebDriver::Firefox::Options.new
options.args << '--headless' unless ENV['NO_HEADLESS'].present?
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: ENV['MARIONETTE'].present?)
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options, desired_capabilities: capabilities)
options = Selenium::WebDriver::Options.firefox
options.add_argument('-headless') unless ENV['NO_HEADLESS'].present?

Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
end
end

0 comments on commit 31adcf5

Please sign in to comment.