page_magic 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/VERSION +1 -1
- data/lib/page_magic.rb +11 -6
- data/spec/page_magic_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a818b71ddcc138a95601f724bcae9b6631bf87431a9bbd7edb0816f1bdac5fb8
|
4
|
+
data.tar.gz: 2d6a165aec8c854e49496c6375154c90aa714b97e28f00fa5cefc5d954fe8dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6145762ea0b3ddc8cea37e04957a95873b6d892798efe051d1f3e3937ebc9c6487e1ab9123dc02544190cf77ac3957197dcd0eaf14e87ce5b104c682aee21696
|
7
|
+
data.tar.gz: d5fc4d9729c2a68bab771e0f4538ed4346daa91a23a53b65cacbe8b75fff02e1ee83e68eef87f77bc5925852a2b1fbd0520e0f3bff2b85f5a2653f408c231faf
|
data/README.md
CHANGED
@@ -56,6 +56,8 @@ Check it out :)
|
|
56
56
|
- [Helper Methods](#helper-methods)
|
57
57
|
- [Dynamic Selectors](#dynamic-selectors)
|
58
58
|
- [Starting a session](#starting-a-session)
|
59
|
+
- [Using an existing session](#using-an-existing-session)
|
60
|
+
- [Rack applications and Rack::Test](#rack-applications-and-racktest)
|
59
61
|
- [Page mapping](#page-mapping)
|
60
62
|
- [Mapping against query string parameters](#mapping-against-query-string-parameters)
|
61
63
|
- [Mapping against fragment identifiers](#mapping-against-fragment-identifiers)
|
@@ -325,9 +327,16 @@ session = PageMagic.session(browser: :chrome, url: 'https://www.github.com')
|
|
325
327
|
```
|
326
328
|
|
327
329
|
Your session won't do much besides navigating to the given url until you have [mapped pages](#page-mapping) to it, so
|
328
|
-
take a look at this next!
|
330
|
+
take a look at this next!
|
329
331
|
|
330
332
|
**Note** PageMagic supports having multiple sessions using different browsers at the same time :)
|
333
|
+
|
334
|
+
## Using an existing session
|
335
|
+
If you are introducing PageMagic in to a test suite that already makes use of Capybara, PageMagic can be configured to
|
336
|
+
make use of the session that is already configure like this:
|
337
|
+
```ruby
|
338
|
+
session = PageMagic.session(session: Capybara.current_session)
|
339
|
+
```
|
331
340
|
|
332
341
|
## Rack applications and Rack::Test
|
333
342
|
To run a session against a rack application instead of a live site, simply supply the rack application when creating
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/lib/page_magic.rb
CHANGED
@@ -50,16 +50,21 @@ module PageMagic
|
|
50
50
|
# @param [Symbol] browser name of browser
|
51
51
|
# @param [String] url url to start the session on
|
52
52
|
# @param [Hash] options browser driver specific options
|
53
|
+
# @param [Capybara::Session] session - use you own already configure capybara session e.g. Capybara.current_session
|
53
54
|
# @return [Session] configured session
|
54
|
-
def session(url: nil, application: nil, browser: :rack_test, options: {})
|
55
|
-
|
56
|
-
|
55
|
+
def session(session: nil, url: nil, application: nil, browser: :rack_test, options: {})
|
56
|
+
session ||= begin
|
57
|
+
driver = drivers.find(browser)
|
58
|
+
raise UnsupportedBrowserException unless driver
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
+
Capybara.register_driver browser do |app|
|
61
|
+
driver.build(app, browser: browser, options: options)
|
62
|
+
end
|
63
|
+
|
64
|
+
Capybara::Session.new(browser, application)
|
60
65
|
end
|
61
66
|
|
62
|
-
Session.new(
|
67
|
+
Session.new(session, url)
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
data/spec/page_magic_spec.rb
CHANGED
@@ -89,6 +89,13 @@ RSpec.describe PageMagic do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
context 'when `session` is specified' do
|
93
|
+
it 'uses it' do
|
94
|
+
session = described_class.session(session: :custom_session)
|
95
|
+
expect(session.raw_session).to be(:custom_session)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
92
99
|
context 'when `:options` is specified' do
|
93
100
|
it 'passes the options to the browser driver' do
|
94
101
|
options = { option: :config }
|