show_me_the_cookies 4.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Changelog.md +43 -0
- data/Gemfile +1 -3
- data/Gemfile.lock +56 -68
- data/README.md +5 -4
- data/lib/show_me_the_cookies/adapters/rack_test.rb +1 -1
- data/lib/show_me_the_cookies/version.rb +1 -1
- data/lib/show_me_the_cookies.rb +2 -5
- data/show_me_the_cookies.gemspec +0 -2
- data/spec/drivers/{selenium_firefox_spec.rb → selenium_chrome_headless_spec.rb} +2 -12
- data/spec/drivers/selenium_chrome_spec.rb +2 -17
- data/spec/drivers/selenium_headless_spec.rb +21 -0
- data/spec/drivers/selenium_spec.rb +19 -0
- data/spec/shared_examples_for_api.rb +1 -1
- data/spec/spec_helper.rb +4 -1
- metadata +8 -19
- data/lib/show_me_the_cookies/adapters/poltergeist.rb +0 -50
- data/lib/show_me_the_cookies/adapters/webkit.rb +0 -59
- data/spec/drivers/poltergeist_spec.rb +0 -27
- data/spec/drivers/webkit_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 733e1bf58e719ff4734c5ab7992c0d2f450e20e4bd4adb9e561660586e365f81
|
4
|
+
data.tar.gz: 56bbc390e84918eae097eb1a6b877197dd52a89ff34ed2f3f5550f65664bbdeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1036a7874266a20ce068f0be468a9a1d524aeca7557398ded8398c63964d3fc8c6e7ae473ba9f472bb0fb05f94e95802777d354580aed5d3e3772507e297b56a
|
7
|
+
data.tar.gz: 3ce7610725681a70d5e49c6b419e13f734b29b5e6f9a002170ade038f1d24554d2c44f54e2f30001fedde41420a493fcad8fce4cc8b6d85aadf588628773882c
|
data/Changelog.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# 6.0.0
|
2
|
+
|
3
|
+
## Breaking change: Poltergeist removed
|
4
|
+
|
5
|
+
It's been obsolete for a while now. If you still need it, you can copy the driver / registration into your app's test code.
|
6
|
+
|
7
|
+
## Fix incompatibility with rack-test 2.0
|
8
|
+
|
9
|
+
Thanks juno. https://github.com/nruth/show_me_the_cookies/pull/64
|
10
|
+
This will likely break rack-test 1.x as it uses new methods/API to get the cookie store.
|
11
|
+
To restore that, override the changed code in your test setup, or register a custom
|
12
|
+
rack-test1 driver based on the old code.
|
13
|
+
|
14
|
+
# 5.0.1
|
15
|
+
|
16
|
+
## Gem development dependencies
|
17
|
+
|
18
|
+
chromedriver-helper -> webdrivers. Bundler -> 2.0.2. Should not affect your app.
|
19
|
+
|
20
|
+
# 5.0
|
21
|
+
|
22
|
+
## Capybara-webkit removed
|
23
|
+
|
24
|
+
Due to obsolescence and maintenance difficulty.
|
25
|
+
Setting up capybara-webkit and qt has never been fun, but now it's getting
|
26
|
+
silly: According to the [capybara-webkit wiki](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit) Qt has removed the necessary webkit bindings, and homebrew has removed the old version of qt that still had them.
|
27
|
+
|
28
|
+
New / current projects should switch to headless Chrome or Firefox with webdriver, which will work with the existing adapters, but if you need the webkit driver for legacy apps stick with version 4, or copy the adapter from version 4 into your app's test support code.
|
29
|
+
|
30
|
+
## Chrome and Firefox driver names
|
31
|
+
|
32
|
+
Drivers are now registered matching the names used by [capybara](https://github.com/teamcapybara/capybara):
|
33
|
+
|
34
|
+
:selenium => Selenium driving Firefox
|
35
|
+
:selenium_headless => Selenium driving Firefox in a headless configuration
|
36
|
+
:selenium_chrome => Selenium driving Chrome
|
37
|
+
:selenium_chrome_headless => Selenium driving Chrome in a headless configuration
|
38
|
+
|
39
|
+
# 4.0
|
40
|
+
|
41
|
+
Changes some cookie escaping logic & supports capybara 3.
|
42
|
+
|
43
|
+
For more information see the release commit: [cc0a1106d9cb00827aeda3301f5b75d6d10e80ba](https://github.com/nruth/show_me_the_cookies/commit/cc0a1106d9cb00827aeda3301f5b75d6d10e80ba)
|
data/Gemfile
CHANGED
@@ -7,9 +7,7 @@ gem 'rake' # for releases
|
|
7
7
|
|
8
8
|
group :test do
|
9
9
|
gem 'rspec', '~> 3.0'
|
10
|
-
gem 'poltergeist', git: 'https://github.com/teampoltergeist/poltergeist', ref: 'f822d3a'
|
11
10
|
gem 'sinatra'
|
12
11
|
gem 'selenium-webdriver'
|
13
|
-
gem '
|
14
|
-
gem 'capybara-webkit'
|
12
|
+
gem 'webdrivers', require: false # chromedriver installer
|
15
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,99 +1,87 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/teampoltergeist/poltergeist
|
3
|
-
revision: f822d3acbe110669420c311484e3dfafa2d31e18
|
4
|
-
ref: f822d3a
|
5
|
-
specs:
|
6
|
-
poltergeist (1.17.0)
|
7
|
-
capybara (>= 2.1, < 4)
|
8
|
-
cliver (~> 0.3.1)
|
9
|
-
websocket-driver (>= 0.2.0)
|
10
|
-
|
11
1
|
PATH
|
12
2
|
remote: .
|
13
3
|
specs:
|
14
|
-
show_me_the_cookies (
|
4
|
+
show_me_the_cookies (6.0.0)
|
15
5
|
capybara (>= 2, < 4)
|
16
6
|
|
17
7
|
GEM
|
18
8
|
remote: http://rubygems.org/
|
19
9
|
specs:
|
20
|
-
addressable (2.
|
21
|
-
public_suffix (>= 2.0.2, <
|
22
|
-
|
23
|
-
io-like (~> 0.3.0)
|
24
|
-
capybara (3.0.1)
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
capybara (3.37.1)
|
25
13
|
addressable
|
14
|
+
matrix
|
26
15
|
mini_mime (>= 0.1.3)
|
27
16
|
nokogiri (~> 1.8)
|
28
17
|
rack (>= 1.6.0)
|
29
18
|
rack-test (>= 0.6.3)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
mustermann (1.0.2)
|
47
|
-
nokogiri (1.8.2)
|
48
|
-
mini_portile2 (~> 2.3.0)
|
49
|
-
public_suffix (3.0.2)
|
50
|
-
rack (2.0.4)
|
51
|
-
rack-protection (2.0.1)
|
19
|
+
regexp_parser (>= 1.5, < 3.0)
|
20
|
+
xpath (~> 3.2)
|
21
|
+
childprocess (4.1.0)
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
matrix (0.4.2)
|
24
|
+
mini_mime (1.1.2)
|
25
|
+
mini_portile2 (2.8.0)
|
26
|
+
mustermann (1.1.1)
|
27
|
+
ruby2_keywords (~> 0.0.1)
|
28
|
+
nokogiri (1.13.7)
|
29
|
+
mini_portile2 (~> 2.8.0)
|
30
|
+
racc (~> 1.4)
|
31
|
+
public_suffix (4.0.7)
|
32
|
+
racc (1.6.0)
|
33
|
+
rack (2.2.4)
|
34
|
+
rack-protection (2.2.0)
|
52
35
|
rack
|
53
|
-
rack-test (
|
54
|
-
rack (>= 1.
|
55
|
-
rake (
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
rspec-
|
60
|
-
|
61
|
-
rspec-
|
62
|
-
rspec-
|
36
|
+
rack-test (2.0.2)
|
37
|
+
rack (>= 1.3)
|
38
|
+
rake (13.0.6)
|
39
|
+
regexp_parser (2.5.0)
|
40
|
+
rexml (3.2.5)
|
41
|
+
rspec (3.11.0)
|
42
|
+
rspec-core (~> 3.11.0)
|
43
|
+
rspec-expectations (~> 3.11.0)
|
44
|
+
rspec-mocks (~> 3.11.0)
|
45
|
+
rspec-core (3.11.0)
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-expectations (3.11.0)
|
63
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-mocks (3.
|
49
|
+
rspec-support (~> 3.11.0)
|
50
|
+
rspec-mocks (3.11.1)
|
66
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-support (3.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
52
|
+
rspec-support (~> 3.11.0)
|
53
|
+
rspec-support (3.11.0)
|
54
|
+
ruby2_keywords (0.0.5)
|
55
|
+
rubyzip (2.3.2)
|
56
|
+
selenium-webdriver (4.3.0)
|
57
|
+
childprocess (>= 0.5, < 5.0)
|
58
|
+
rexml (~> 3.2, >= 3.2.5)
|
59
|
+
rubyzip (>= 1.2.2, < 3.0)
|
60
|
+
websocket (~> 1.0)
|
61
|
+
sinatra (2.2.0)
|
74
62
|
mustermann (~> 1.0)
|
75
|
-
rack (~> 2.
|
76
|
-
rack-protection (= 2.0
|
63
|
+
rack (~> 2.2)
|
64
|
+
rack-protection (= 2.2.0)
|
77
65
|
tilt (~> 2.0)
|
78
|
-
tilt (2.0.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
66
|
+
tilt (2.0.10)
|
67
|
+
webdrivers (5.0.0)
|
68
|
+
nokogiri (~> 1.6)
|
69
|
+
rubyzip (>= 1.3.0)
|
70
|
+
selenium-webdriver (~> 4.0)
|
71
|
+
websocket (1.2.9)
|
72
|
+
xpath (3.2.0)
|
83
73
|
nokogiri (~> 1.8)
|
84
74
|
|
85
75
|
PLATFORMS
|
86
76
|
ruby
|
87
77
|
|
88
78
|
DEPENDENCIES
|
89
|
-
capybara-webkit
|
90
|
-
chromedriver-helper
|
91
|
-
poltergeist!
|
92
79
|
rake
|
93
80
|
rspec (~> 3.0)
|
94
81
|
selenium-webdriver
|
95
82
|
show_me_the_cookies!
|
96
83
|
sinatra
|
84
|
+
webdrivers
|
97
85
|
|
98
86
|
BUNDLED WITH
|
99
|
-
|
87
|
+
2.2.16
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Show me the cookies
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/projects/9a0dc444-fd04-4187-95a7-7a07abecbad7/201807/shields_badge.png)](https://semaphoreci.com/nruth/show_me_the_cookies) [![Gem Version](https://badge.fury.io/rb/show_me_the_cookies.svg)](http://badge.fury.io/rb/show_me_the_cookies)
|
4
4
|
|
5
|
-
Some helpers for poking around at your Capybara driven browser's cookies in integration tests.
|
5
|
+
Some helpers for poking around at your Capybara driven browser's cookies in integration tests.
|
6
6
|
|
7
|
-
Provides drivers for rack-test
|
8
|
-
|
7
|
+
Provides drivers for rack-test and [selenium-webdriver](https://rubygems.org/gems/selenium-webdriver).
|
8
|
+
|
9
|
+
You can add new drivers to your application by implementing an adapter class and calling ShowMeTheCookies.register_adapter in your test code (e.g. a spec/support file). But in that case you might prefer to skip this gem and use your driver's api directly.
|
9
10
|
|
10
11
|
## API
|
11
12
|
|
data/lib/show_me_the_cookies.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module ShowMeTheCookies
|
2
2
|
require 'show_me_the_cookies/adapters/rack_test'
|
3
|
-
require 'show_me_the_cookies/adapters/poltergeist'
|
4
3
|
require 'show_me_the_cookies/adapters/selenium'
|
5
4
|
require 'show_me_the_cookies/adapters/selenium_chrome'
|
6
|
-
require 'show_me_the_cookies/adapters/webkit'
|
7
5
|
|
8
6
|
@adapters = {}
|
9
7
|
class << self
|
@@ -19,11 +17,10 @@ module ShowMeTheCookies
|
|
19
17
|
|
20
18
|
# to register your own adapter/driver do this in your test setup code somewhere e.g. spec/support
|
21
19
|
register_adapter(:selenium, ShowMeTheCookies::Selenium)
|
20
|
+
register_adapter(:selenium_headless, ShowMeTheCookies::Selenium)
|
22
21
|
register_adapter(:selenium_chrome, ShowMeTheCookies::SeleniumChrome)
|
22
|
+
register_adapter(:selenium_chrome_headless, ShowMeTheCookies::SeleniumChrome)
|
23
23
|
register_adapter(:rack_test, ShowMeTheCookies::RackTest)
|
24
|
-
register_adapter(:poltergeist, ShowMeTheCookies::Poltergeist)
|
25
|
-
register_adapter(:webkit, ShowMeTheCookies::Webkit)
|
26
|
-
register_adapter(:webkit_debug, ShowMeTheCookies::Webkit)
|
27
24
|
|
28
25
|
# puts a string summary of the cookie
|
29
26
|
def show_me_the_cookie(cookie_name)
|
data/show_me_the_cookies.gemspec
CHANGED
@@ -14,8 +14,6 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.licenses = ["MIT"]
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
s.add_dependency('capybara', ['>= 2', '< 4'])
|
21
19
|
end
|
@@ -1,18 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'shared_examples_for_api'
|
3
|
-
require 'selenium-webdriver'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
Capybara.register_driver :selenium do |app|
|
8
|
-
options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'])
|
9
|
-
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.describe 'Selenium Webdriver Firefox', type: :feature do
|
13
|
-
before(:each) do
|
14
|
-
Capybara.current_driver = :selenium
|
15
|
-
end
|
4
|
+
RSpec.describe 'Selenium Webdriver Headless Chrome', type: :feature,
|
5
|
+
driver: :selenium_chrome_headless do
|
16
6
|
|
17
7
|
describe 'the testing rig' do
|
18
8
|
it 'should load the sinatra app' do
|
@@ -1,23 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'shared_examples_for_api'
|
3
|
-
require "selenium/webdriver"
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
chromeOptions: { args: %w(headless disable-gpu) },
|
8
|
-
)
|
9
|
-
|
10
|
-
Capybara::Selenium::Driver.new(
|
11
|
-
app,
|
12
|
-
browser: :chrome,
|
13
|
-
desired_capabilities: capabilities,
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
RSpec.describe 'Selenium Webdriver Chrome', type: :feature do
|
18
|
-
before(:each) do
|
19
|
-
Capybara.current_driver = :selenium_chrome
|
20
|
-
end
|
4
|
+
RSpec.describe 'Selenium Webdriver Chrome', type: :feature,
|
5
|
+
driver: :selenium_chrome do
|
21
6
|
|
22
7
|
describe 'the testing rig' do
|
23
8
|
it 'should load the sinatra app' do
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared_examples_for_api'
|
3
|
+
|
4
|
+
RSpec.describe 'Selenium Webdriver Firefox Headless', type: :feature,
|
5
|
+
driver: :selenium_headless do
|
6
|
+
|
7
|
+
describe 'the testing rig' do
|
8
|
+
it 'should load the sinatra app' do
|
9
|
+
visit '/'
|
10
|
+
expect(page).to have_content('Cookie setter ready')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like 'the API'
|
15
|
+
|
16
|
+
it 'raises an exception when writing a cookie before visiting the app' do
|
17
|
+
expect { create_cookie('choc', 'milk') }.to(
|
18
|
+
raise_error(ShowMeTheCookies::SeleniumSiteNotVisitedError)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared_examples_for_api'
|
3
|
+
|
4
|
+
RSpec.describe 'Selenium Webdriver Firefox', type: :feature, driver: :selenium do
|
5
|
+
describe 'the testing rig' do
|
6
|
+
it 'should load the sinatra app' do
|
7
|
+
visit '/'
|
8
|
+
expect(page).to have_content('Cookie setter ready')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like 'the API'
|
13
|
+
|
14
|
+
it 'raises an exception when writing a cookie before visiting the app' do
|
15
|
+
expect { create_cookie('choc', 'milk') }.to(
|
16
|
+
raise_error(ShowMeTheCookies::SeleniumSiteNotVisitedError)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require 'capybara/rspec'
|
2
2
|
|
3
|
+
require 'webdrivers'
|
4
|
+
|
3
5
|
# puma dependency unnecessary for this small project, just use stdlib
|
4
6
|
Capybara.server = :webrick
|
5
7
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
8
|
+
require File.join(File.dirname(__FILE__), "app", "set_cookie")
|
7
9
|
Capybara.app = Sinatra::Application
|
8
10
|
|
9
11
|
require 'show_me_the_cookies'
|
10
12
|
RSpec.configure do |config|
|
11
13
|
config.include(ShowMeTheCookies, type: :feature)
|
14
|
+
config.disable_monkey_patching!
|
12
15
|
end
|
13
16
|
|
14
17
|
Capybara.server_port = 36363
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: show_me_the_cookies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Rutherford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -38,25 +38,24 @@ extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- ".gitignore"
|
41
|
+
- Changelog.md
|
41
42
|
- Gemfile
|
42
43
|
- Gemfile.lock
|
43
44
|
- README.md
|
44
45
|
- Rakefile
|
45
46
|
- lib/show_me_the_cookies.rb
|
46
|
-
- lib/show_me_the_cookies/adapters/poltergeist.rb
|
47
47
|
- lib/show_me_the_cookies/adapters/rack_test.rb
|
48
48
|
- lib/show_me_the_cookies/adapters/selenium.rb
|
49
49
|
- lib/show_me_the_cookies/adapters/selenium_chrome.rb
|
50
|
-
- lib/show_me_the_cookies/adapters/webkit.rb
|
51
50
|
- lib/show_me_the_cookies/version.rb
|
52
51
|
- show_me_the_cookies.gemspec
|
53
52
|
- spec/app/set_cookie.rb
|
54
|
-
- spec/drivers/poltergeist_spec.rb
|
55
53
|
- spec/drivers/rack-test_spec.rb
|
54
|
+
- spec/drivers/selenium_chrome_headless_spec.rb
|
56
55
|
- spec/drivers/selenium_chrome_spec.rb
|
57
|
-
- spec/drivers/
|
56
|
+
- spec/drivers/selenium_headless_spec.rb
|
57
|
+
- spec/drivers/selenium_spec.rb
|
58
58
|
- spec/drivers/unknown_driver_spec.rb
|
59
|
-
- spec/drivers/webkit_spec.rb
|
60
59
|
- spec/shared_examples_for_api.rb
|
61
60
|
- spec/spec_helper.rb
|
62
61
|
homepage: https://github.com/nruth/show_me_the_cookies
|
@@ -78,18 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: '0'
|
80
79
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.6.14
|
80
|
+
rubygems_version: 3.1.6
|
83
81
|
signing_key:
|
84
82
|
specification_version: 4
|
85
83
|
summary: Cookie manipulation for Capybara drivers
|
86
|
-
test_files:
|
87
|
-
- spec/app/set_cookie.rb
|
88
|
-
- spec/drivers/poltergeist_spec.rb
|
89
|
-
- spec/drivers/rack-test_spec.rb
|
90
|
-
- spec/drivers/selenium_chrome_spec.rb
|
91
|
-
- spec/drivers/selenium_firefox_spec.rb
|
92
|
-
- spec/drivers/unknown_driver_spec.rb
|
93
|
-
- spec/drivers/webkit_spec.rb
|
94
|
-
- spec/shared_examples_for_api.rb
|
95
|
-
- spec/spec_helper.rb
|
84
|
+
test_files: []
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module ShowMeTheCookies
|
2
|
-
class Poltergeist
|
3
|
-
def initialize(driver)
|
4
|
-
@browser = driver.browser
|
5
|
-
@driver = driver
|
6
|
-
end
|
7
|
-
|
8
|
-
def get_me_the_cookie(name)
|
9
|
-
cookie = cookies_hash[name.to_s]
|
10
|
-
translate(cookie) unless cookie.nil?
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_me_the_cookies
|
14
|
-
cookies_hash.values.map(&method(:translate))
|
15
|
-
end
|
16
|
-
|
17
|
-
def expire_cookies
|
18
|
-
cookies_hash.each do |name, cookie|
|
19
|
-
delete_cookie(name) if (cookie.expires rescue nil).nil?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def delete_cookie(name)
|
24
|
-
@browser.remove_cookie(name.to_s)
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_cookie(name, value, options)
|
28
|
-
# see: https://github.com/jonleighton/poltergeist#manipulating-cookies
|
29
|
-
@driver.set_cookie(name, value, options)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def cookies_hash
|
35
|
-
@browser.cookies
|
36
|
-
end
|
37
|
-
|
38
|
-
def translate(cookie)
|
39
|
-
{
|
40
|
-
:name => cookie.name,
|
41
|
-
:domain => cookie.domain,
|
42
|
-
:value => cookie.value,
|
43
|
-
:expires => (cookie.expires rescue nil),
|
44
|
-
:path => cookie.path,
|
45
|
-
:secure => cookie.secure?,
|
46
|
-
:httponly => cookie.httponly?
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module ShowMeTheCookies
|
2
|
-
class Webkit
|
3
|
-
def initialize(driver)
|
4
|
-
@driver = driver
|
5
|
-
end
|
6
|
-
|
7
|
-
def get_me_the_cookie(name)
|
8
|
-
cookie = cookie_jar.find(name)
|
9
|
-
translate(cookie) unless cookie.nil?
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_me_the_cookies
|
13
|
-
cookies.each.map(&method(:translate))
|
14
|
-
end
|
15
|
-
|
16
|
-
def expire_cookies
|
17
|
-
cookies.each do |cookie|
|
18
|
-
delete_cookie(cookie.name) if cookie.expires.nil?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Since QTWebkit doesn't seem to offer deletion, clearing all and re-setting the rest seems to be it
|
23
|
-
def delete_cookie(name)
|
24
|
-
old_cookies = cookies
|
25
|
-
@driver.clear_cookies
|
26
|
-
old_cookies.each do |cookie|
|
27
|
-
@driver.set_cookie(cookie) unless cookie.name == name.to_s
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_cookie(name, value, options)
|
32
|
-
host = options.delete(:domain) || (Capybara.app_host ? URI(Capybara.app_host).host : '127.0.0.1')
|
33
|
-
puts "Webkit create_cookie options not supported: #{options.inspect}" if options && (options != {})
|
34
|
-
@driver.set_cookie("#{name}=#{Rack::Utils.escape(value)}; domain=#{host}")
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# see https://github.com/thoughtbot/capybara-webkit/blob/master/lib/capybara/webkit/cookie_jar.rb
|
40
|
-
def cookie_jar
|
41
|
-
@driver.cookies
|
42
|
-
end
|
43
|
-
|
44
|
-
def cookies
|
45
|
-
cookie_jar.send("cookies")
|
46
|
-
end
|
47
|
-
|
48
|
-
def translate(cookie)
|
49
|
-
{
|
50
|
-
:name => cookie.name,
|
51
|
-
:domain => cookie.domain,
|
52
|
-
:value => cookie.value,
|
53
|
-
:expires => (cookie.expires rescue nil),
|
54
|
-
:path => cookie.path,
|
55
|
-
:secure => cookie.secure.nil? ? false : true
|
56
|
-
}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shared_examples_for_api'
|
3
|
-
require 'capybara/poltergeist'
|
4
|
-
|
5
|
-
RSpec.describe 'Poltergeist', type: :feature do
|
6
|
-
before(:each) do
|
7
|
-
Capybara.current_driver = :poltergeist
|
8
|
-
end
|
9
|
-
|
10
|
-
describe 'the testing rig' do
|
11
|
-
it 'should load the sinatra app' do
|
12
|
-
visit '/'
|
13
|
-
expect(page).to have_content('Cookie setter ready')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'get_me_the_cookie' do
|
18
|
-
it 'reads httponly option' do
|
19
|
-
visit '/set_httponly/foo/bar'
|
20
|
-
expect(get_me_the_cookie('foo')).to include(
|
21
|
-
name: 'foo', value: 'bar', httponly: true
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it_behaves_like 'the API'
|
27
|
-
end
|
data/spec/drivers/webkit_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shared_examples_for_api'
|
3
|
-
require 'capybara-webkit'
|
4
|
-
|
5
|
-
Capybara::Webkit.configure do |config|
|
6
|
-
config.allow_url("subdomain.lvh.me")
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec.describe 'Webkit', type: :feature do
|
10
|
-
before(:each) do
|
11
|
-
Capybara.current_driver = :webkit
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'the testing rig' do
|
15
|
-
it 'should load the sinatra app' do
|
16
|
-
visit '/'
|
17
|
-
expect(page).to have_content('Cookie setter ready')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it_behaves_like 'the API'
|
22
|
-
end
|