page_magic 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccc04854912ddcf2dd95b493fea787c32a5b4b26f0029a477f06a398d7ae0b00
4
- data.tar.gz: 8d57827aca461954a62e446937f7b58fa27ecda1ac9ac35841aab78cb3120701
3
+ metadata.gz: 7cd51a69161a6e25593df1ee746057e38a23dbd5debcc5d22ea66cd0376df4c5
4
+ data.tar.gz: aea97edeac9689e324e7077fcd208091b5704bd2efb2cc6d62b9980d2f9f15cd
5
5
  SHA512:
6
- metadata.gz: 341434bd29979c0a7d03a97775ed4d1dd173541bb25e67f65afd833caac81f3a917b3b468036f381f64d0a55e2c7d8facbc61ecebef72bc228d85b1de621bf10
7
- data.tar.gz: 66128a080b1337fe28a130e322b712d05ff0a7f1b96c16c77a3c1d3a0c9070222e48712f44ca07175339b3b76b979a0d55b5e8546f7774a31669b60c8862ba2e
6
+ metadata.gz: 47914506ca6a1eaa24bacb0c83a0a8ff750bdf2a7a11bc5d3822218f75e9da0bca9a949b263d6beead2c549c740392ea431ff53bc1cc14cbae1b84b1426f8fea
7
+ data.tar.gz: 2a4c5ae39523e8835321d53ab463ca9d20fe9fe3ec0ddf0b30fb22fbf11d201f2be0e7642c337c4d4f4e9fd19a7cedc64a89d45bbee363296a05b9ead5e0bb51
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.0.5
@@ -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
- def visit(page = nil, url: nil)
79
- url ||= transitions.url_for(page, base_url: base_url)
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(page) if 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(url: expected_url)
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
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-04 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport