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

Improve check for paths as Hashes in CaptureOptions #582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Improve check for paths as Hashes in CaptureOptions
Closes #536
Steve Day authored and Steve Day committed Sep 6, 2018
commit 7734de193aa9ebb9c271d22b574f51eba95f0636
2 changes: 1 addition & 1 deletion lib/wraith/helpers/capture_options.rb
Original file line number Diff line number Diff line change
@@ -47,6 +47,6 @@ def compare_urls(path)
end

def casper?(options)
options["path"] ? options["path"] : options
options.is_a?(String) ? options : options.fetch("path")
end
end
23 changes: 23 additions & 0 deletions spec/helper_spec.rb
Original file line number Diff line number Diff line change
@@ -28,4 +28,27 @@
end
end

describe "CaptureOptions" do
let(:capture_options) { CaptureOptions.new('', nil) }

describe "#casper?" do
it "returns options when options is a string" do
actual = capture_options.casper?('/test/path')
expected = '/test/path'
expect(actual).to eq expected
end

context "when options is a Hash" do
it "returns options['path']" do
actual = capture_options.casper?({'path' => '/test/path'})
expected = '/test/path'
expect(actual).to eq expected
end

it "raises a KeyError if options['path'] is missing" do
expect { capture_options.casper?({}) }.to raise_error(KeyError)
end
end
end
end
end