Skip to content
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

🐛 Gather current_session from Capybara rather than importing the DSL module #168

Merged
merged 2 commits into from
Jun 9, 2021
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
8 changes: 4 additions & 4 deletions lib/percy/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require_relative './version'

module PercyCapybara
include Capybara::DSL

CLIENT_INFO = "percy-capybara/#{VERSION}".freeze
ENV_INFO = "capybara/#{Capybara::VERSION} ruby/#{RUBY_VERSION}".freeze

Expand All @@ -20,10 +18,12 @@ module PercyCapybara
def percy_snapshot(name, options = {})
return unless percy_enabled?

page = Capybara.current_session

begin
page.evaluate_script(fetch_percy_dom)
dom_snapshot =
page.evaluate_script("(function() { return PercyDOM.serialize(#{options.to_json}) })()")
dom_snapshot = page
.evaluate_script("(function() { return PercyDOM.serialize(#{options.to_json}) })()")

response = fetch('percy/snapshot',
name: name,
Expand Down
1 change: 1 addition & 0 deletions spec/lib/percy/percy_capybara_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
environment_info: "capybara/#{Capybara::VERSION} ruby/#{RUBY_VERSION}",
}.to_json,
).once
expect(page).to have_current_path('/index.html')
end
end
end