Skip to content

[0.14.3] Support custom save_path option #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/capybara/cuprite/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def initialize(app, options = {})

@screen_size = @options.delete(:screen_size)
@screen_size ||= DEFAULT_MAXIMIZE_SCREEN_SIZE

@options[:save_path] = File.expand_path(Capybara.save_path) if Capybara.save_path
@options[:save_path] ||= File.expand_path(Capybara.save_path) if Capybara.save_path

ENV["FERRUM_DEBUG"] = "true" if ENV["CUPRITE_DEBUG"]

Expand Down
33 changes: 33 additions & 0 deletions spec/lib/driver_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

describe Capybara::Cuprite::Driver do
describe "save_path configuration" do
it "defaults to the Capybara save path" do
driver = with_capybara_save_path("/tmp/capybara-save-path") do
described_class.new(nil)
end

expect(driver.browser.options.to_h).to include(save_path: "/tmp/capybara-save-path")
end

it "allows a custom path to be specified" do
custom_path = Dir.mktmpdir

driver = with_capybara_save_path("/tmp/capybara-save-path") do
described_class.new(nil, { save_path: custom_path })
end

expect(driver.browser.options.to_h).to include(save_path: custom_path)
end
end

private

def with_capybara_save_path(path)
original_capybara_save_path = Capybara.save_path
Capybara.save_path = path
yield
ensure
Capybara.save_path = original_capybara_save_path
end
end