Skip to content

Commit

Permalink
skip screenshots in rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattades committed May 14, 2024
1 parent 6b2d48b commit 73bb866
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/cyperful.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ def self.add_step_at_methods(*mods_or_methods)
require "cyperful/test_parser"
require "cyperful/ui_server"
require "cyperful/driver"
require "cyperful/framework_helper"
require "cyperful/framework_injections"
require "cyperful/railtie" if defined?(Rails::Railtie)
7 changes: 7 additions & 0 deletions lib/cyperful/framework_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Cyperful::FrameworkHelper
# Disable default screenshot on failure b/c we handle them ourselves.
# https://github.com/rails/rails/blob/v7.0.1/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L156
def take_failed_screenshot
nil
end
end
3 changes: 0 additions & 3 deletions lib/cyperful/framework_injections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ def initialize(...)
# hide the "Chrome is being controlled by automated test software" infobar
driver_opts.args.delete("--enable-automation")
driver_opts.exclude_switches << "enable-automation"

pp args: driver_opts.args,
exclude_switches: driver_opts.exclude_switches
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions lib/cyperful/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

module Cyperful::Minitest # rubocop:disable Style/ClassAndModuleChildren
module SystemTestHelper
include Cyperful::FrameworkHelper

def setup
Cyperful.setup(self.class, self.method_name)
super
Expand All @@ -16,12 +18,6 @@ def teardown
Cyperful.teardown(error)
super
end

# Disable default screenshot on failure b/c we handle them ourselves.
# https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L156
def take_failed_screenshot
nil
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/cyperful/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Cyperful::Rspec
def self.configure(rspec_conf)
rspec_conf.include(Cyperful::FrameworkHelper)

rspec_conf.before(:example, type: :system) do
# e.g. class = `RSpec::ExampleGroups::MyTest`
# e.g. full_description = "my_test can visit root"
Expand All @@ -11,7 +13,7 @@ def self.configure(rspec_conf)

rspec_conf.after(:example, type: :system) do
example = RSpec.current_example
error = example.exception
error = example.exception # may be nil

# if error.is_a?(RSpec::Expectations::ExpectationNotMetError)
# error = error.error
Expand Down
3 changes: 1 addition & 2 deletions test/dummy/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ group :test do
gem "capybara"
gem "selenium-webdriver"

# manually load test-frameworks since we support multiple
gem "rspec-rails"
gem "rspec-rails" # should we require=false this?

gem "cyperful", path: "../..", require: false
end

0 comments on commit 73bb866

Please sign in to comment.