Files
openfoodnetwork/spec/system/support/cuprite_setup.rb
Neal Chambers 7c14853add Safely autocorrect Style/RedundantDoubleSplatHashBraces
Inspecting 1509 files
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...............

Offenses:

spec/system/support/cuprite_setup.rb:13:5: C: [Corrected] Style/RedundantDoubleSplatHashBraces: Remove the redundant double splat and braces, use keyword arguments directly.
    **{ ...
    ^^^
spec/system/support/cuprite_setup.rb:14:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      browser_options:,
      ^^^^^^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:15:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      process_timeout: 60,
      ^^^^^^^^^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:16:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      timeout: 60,
      ^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:17:7: C: [Corrected] Layout/CommentIndentation: Incorrect indentation detected (column 6 instead of 4).
      # Don't load scripts from external sources, like google maps or stripe
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:18:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      url_whitelist: ["http://localhost", "http://0.0.0.0", "http://127.0.0.1"],
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:19:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      inspector: true,
      ^^^^^^^^^^^^^^^
spec/system/support/cuprite_setup.rb:20:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      headless:,
      ^^^^^^^^^
spec/system/support/cuprite_setup.rb:21:7: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
      js_errors: true
      ^^^^^^^^^^^^^^^

1509 files inspected, 9 offenses detected, 9 offenses corrected
2023-11-10 09:13:57 +09:00

44 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require "capybara/cuprite"
headless = ActiveModel::Type::Boolean.new.cast(ENV.fetch("HEADLESS", true))
browser_options = {}
browser_options["no-sandbox"] = nil if ENV['CI']
Capybara.register_driver(:cuprite_ofn) do |app|
Capybara::Cuprite::Driver.new(
app,
window_size: [1280, 800],
browser_options:,
process_timeout: 60,
timeout: 60,
# Don't load scripts from external sources, like google maps or stripe
url_whitelist: ["http://localhost", "http://0.0.0.0", "http://127.0.0.1"],
inspector: true,
headless:,
js_errors: true
)
end
# Configure Capybara to use :cuprite_ofn driver by default
Capybara.default_driver = Capybara.javascript_driver = :cuprite_ofn
RSpec.configure do |config|
config.include CupriteHelpers, type: :system
config.include Devise::Test::IntegrationHelpers, type: :system
config.prepend_before(:each, type: :system) { driven_by :cuprite_ofn }
# Make sure url helpers in mailers use the Capybara server host.
config.around(:each, type: :system) do |example|
original_host = Rails.application.default_url_options[:host]
Rails.application.default_url_options[:host] =
"#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}"
example.run
Rails.application.default_url_options[:host] = original_host
remove_downloaded_files
end
end