page_magic 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/page_magic/session.rb +12 -3
- data/spec/page_magic/session_spec.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cd51a69161a6e25593df1ee746057e38a23dbd5debcc5d22ea66cd0376df4c5
|
4
|
+
data.tar.gz: aea97edeac9689e324e7077fcd208091b5704bd2efb2cc6d62b9980d2f9f15cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47914506ca6a1eaa24bacb0c83a0a8ff750bdf2a7a11bc5d3822218f75e9da0bca9a949b263d6beead2c549c740392ea431ff53bc1cc14cbae1b84b1426f8fea
|
7
|
+
data.tar.gz: 2a4c5ae39523e8835321d53ab463ca9d20fe9fe3ec0ddf0b30fb22fbf11d201f2be0e7642c337c4d4f4e9fd19a7cedc64a89d45bbee363296a05b9ead5e0bb51
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.5
|
data/lib/page_magic/session.rb
CHANGED
@@ -18,6 +18,8 @@ module PageMagic
|
|
18
18
|
# Create a new session instance
|
19
19
|
# @param [Object] capybara_session an instance of a capybara session
|
20
20
|
# @param [String] base_url url to start the session at.
|
21
|
+
#
|
22
|
+
|
21
23
|
def initialize(capybara_session, base_url = nil)
|
22
24
|
@raw_session = capybara_session
|
23
25
|
@base_url = base_url
|
@@ -44,6 +46,12 @@ module PageMagic
|
|
44
46
|
@transitions = Transitions.new(transitions)
|
45
47
|
end
|
46
48
|
|
49
|
+
def is_a?(klass)
|
50
|
+
return true if klass == Capybara::Session
|
51
|
+
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
47
55
|
# proxies unknown method calls to the currently loaded page object
|
48
56
|
# @return [Object] returned object from the page object method call
|
49
57
|
def method_missing(name, *args, &block)
|
@@ -75,13 +83,14 @@ module PageMagic
|
|
75
83
|
# @raise [InvalidURLException] if a page is supplied and there isn't a mapped path for it
|
76
84
|
# @raise [InvalidURLException] if neither a page or url are supplied
|
77
85
|
# @raise [InvalidURLException] if the mapped path for a page is a Regexp
|
78
|
-
|
79
|
-
|
86
|
+
# @return [PageMagic::Session] - returns self
|
87
|
+
def visit(page_or_url = nil, url: nil)
|
88
|
+
url ||= page_or_url.is_a?(String) ? page_or_url : transitions.url_for(page_or_url, base_url: base_url)
|
80
89
|
|
81
90
|
raise InvalidURLException, URL_MISSING_MSG unless url
|
82
91
|
|
83
92
|
raw_session.visit(url)
|
84
|
-
@current_page = initialize_page(
|
93
|
+
@current_page = initialize_page(page_or_url) unless page_or_url.is_a?(String)
|
85
94
|
self
|
86
95
|
end
|
87
96
|
|
@@ -79,6 +79,14 @@ RSpec.describe PageMagic::Session do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe '#is_a?' do
|
83
|
+
context 'when other is a `Capybara::Session`' do
|
84
|
+
it 'returns true' do
|
85
|
+
expect(described_class.new(browser).is_a?(Capybara::Session)).to eq(true)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
82
90
|
describe '#respond_to?' do
|
83
91
|
it 'checks self' do
|
84
92
|
session = described_class.new(browser)
|
@@ -138,10 +146,17 @@ RSpec.describe PageMagic::Session do
|
|
138
146
|
end
|
139
147
|
end
|
140
148
|
|
149
|
+
context 'when a page and `:url` supplied' do
|
150
|
+
it 'uses the url' do
|
151
|
+
session.visit(page, url: 'http://other.url/')
|
152
|
+
expect(session.current_url).to eq('http://other.url/')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
141
156
|
context 'when `url` is supplied' do
|
142
157
|
it 'visits that url' do
|
143
158
|
expected_url = 'http://base.url/page'
|
144
|
-
session.visit(
|
159
|
+
session.visit(expected_url)
|
145
160
|
expect(browser.current_url).to eq(expected_url)
|
146
161
|
end
|
147
162
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leon Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|