webaccount 0.4.0 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 219aecddbc5a0e05b1463300ade4350d9afd789de19f1a43fe34e492d5ad9296
4
- data.tar.gz: 6cbc7db55da4afc34b164f3a8a163da4e4e716b313e09b266d2453c98af0c115
3
+ metadata.gz: 90b5b4da3fa0eee7ac4a4c6c85ce3b59a7640bc7aaff8065b7c8432920d8a255
4
+ data.tar.gz: 1a5efd14b2d09b0dd2d6eeaef4128272d7e34e18779e62cf968a95455858ee1a
5
5
  SHA512:
6
- metadata.gz: fdb4db1ec12daf5e307f0df3212f51f1eb4da9b1ca505a68a1008e626598d30214f7d235e330b9f856d215efb816c276eb4525a4578937eb7329dedf064d0581
7
- data.tar.gz: b4515525fce7cb22a90b15f7a05ddc3da14cb870c02d4e95d31959a2ff3c3753d74ad96adfb0bd96deb64937f466c20a0ec7ae3395b9d4d43eb59b72b4881dff
6
+ metadata.gz: dbf5f58ce0a99f2232796010962a20f39b45a55e8ba0c5c414b2c3c50ea3c8f54fe409ab4b36878d36a5cf849664b187c3119bc3a79e483c50c2e2196f3b55a8
7
+ data.tar.gz: 935406e37e640aafd799a60a422314282874d0ffc5369fe398dde3b0948987da01583fc649ffdb47ebf58c421c0881fcf2a00dbeabeb5595ad1e92cac890b37c
data/CHANGELOG CHANGED
@@ -1,5 +1,27 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20261011
4
+
5
+ 0.5.0: + WebAccount#driver, public, so that the logged-in browser can be driven from outside.
6
+
7
+ driver was private, so once login() had done its work the session it made could be used only by a sub-class. Something which wants the pages behind a login without being a WebAccount, a spider fetching and screenshotting them, had no way to reach the browser holding the session.
8
+
9
+ 1. ~ WebAccount#driver(): public, after shutdown(); what it does is unchanged, the browser being made once, with browser() and driver_options(), upon first being asked for.
10
+ 2. + test/webaccount_test.rb: driver public, made once, and made with the browser and driver options given, with Selenium::WebDriver.for swapped for a stand-in so that no browser is wanted. All three fail against 0.4.1.
11
+ 3. ~ README.md: + Driving the browser once logged in.
12
+ 4. ~ VERSION: /0.4.1/0.5.0/
13
+
14
+
15
+ ## 20260822
16
+
17
+ 0.4.1: + LICENSE, which the gemspec has claimed without one being present.
18
+
19
+ 1. + LICENSE: the MIT text, copyright 2020-2026 thoran. spec.license has named MIT with no licence text in the repository, so the gem shipped a licence nobody could read.
20
+ 2. ~ webaccount.gemspec: + 'LICENSE' to spec.files, without which the file sits in the repository and still does not ship.
21
+ 3. + README.md: a License section, saying MIT, last.
22
+ 4. ~ VERSION: /0.4.0/0.4.1/
23
+
24
+
3
25
  ## 20260717
4
26
 
5
27
  0.4.0: Selenium 4 compatibility, achieved mostly by deletion, since Selenium 4 has absorbed most of what these extensions were written for.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 thoran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -140,6 +140,18 @@ There are two, both overridable in a sub-class:
140
140
  my_account.shutdown # If necessary it logs out and then kills the selenium session.
141
141
  ```
142
142
 
143
+ ### Driving the browser once logged in
144
+
145
+ `driver` is the logged-in browser, a `Selenium::WebDriver::Driver`, for whatever WebAccount doesn't do itself: fetching pages behind the login, reading them, or taking screenshots of them.
146
+ ```ruby
147
+ my_account = MyAccount.new(username: username, password: password)
148
+ my_account.login
149
+ my_account.driver.get('https://mysite.com/members/page')
150
+ my_account.driver.page_source
151
+ my_account.driver.save_screenshot('page.png')
152
+ my_account.shutdown
153
+ ```
154
+
143
155
  ### Overriding the login method to customise logins
144
156
  ```ruby
145
157
  require 'webaccount'
@@ -179,3 +191,8 @@ Prefer `find` over `driver.find_element`: it waits up to `default_find_timeout`
179
191
  3. Commit your changes: `git commit -am 'Add some feature'`
180
192
  4. Push to the branch: `git push origin my-new-feature`
181
193
  5. Create a new pull request
194
+
195
+
196
+ ## License
197
+
198
+ MIT
@@ -2,5 +2,5 @@
2
2
  # WebAccount::VERSION
3
3
 
4
4
  class WebAccount
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
data/lib/webaccount.rb CHANGED
@@ -56,6 +56,10 @@ class WebAccount
56
56
  driver.quit
57
57
  end
58
58
 
59
+ def driver
60
+ @driver ||= Selenium::WebDriver.for(browser, options: driver_options)
61
+ end
62
+
59
63
  # predicate methods
60
64
 
61
65
  def logged_in?
@@ -88,10 +92,6 @@ class WebAccount
88
92
  @driver_options || default_driver_options
89
93
  end
90
94
 
91
- def driver
92
- @driver ||= Selenium::WebDriver.for(browser, options: driver_options)
93
- end
94
-
95
95
  # waiting
96
96
 
97
97
  # For navigation: a submit, the authentication behind it, and the redirect.
@@ -0,0 +1,45 @@
1
+ # test/webaccount_test.rb
2
+
3
+ # Notes:
4
+ # 1. No browser: Selenium::WebDriver.for is swapped for a stand-in for the length of
5
+ # each example and put back afterwards, so what is asserted is what WebAccount asks
6
+ # of Selenium and what it hands back.
7
+
8
+ require_relative '../lib/webaccount'
9
+
10
+ require 'minitest/autorun'
11
+ require 'minitest-spec-context'
12
+
13
+ describe WebAccount do
14
+ def with_driver_factory(&block)
15
+ calls = []
16
+ stand_in = Object.new
17
+ original = Selenium::WebDriver.method(:for)
18
+ Selenium::WebDriver.define_singleton_method(:for){|browser, options: nil| calls << [browser, options]; stand_in}
19
+ block.call(stand_in, calls)
20
+ ensure
21
+ Selenium::WebDriver.define_singleton_method(:for, original)
22
+ end
23
+
24
+ describe "#driver" do
25
+ it "is public, so that the logged-in browser can be driven from outside" do
26
+ _(WebAccount.public_method_defined?(:driver)).must_equal(true)
27
+ end
28
+
29
+ it "is the browser Selenium made, made once" do
30
+ with_driver_factory do |stand_in, calls|
31
+ account = WebAccount.new
32
+ _(account.driver).must_be_same_as(stand_in)
33
+ _(account.driver).must_be_same_as(stand_in)
34
+ _(calls.length).must_equal(1)
35
+ end
36
+ end
37
+
38
+ it "is made with the browser and driver options given" do
39
+ with_driver_factory do |stand_in, calls|
40
+ WebAccount.new(browser: 'Firefox', driver_options: :options).driver
41
+ _(calls).must_equal([[:firefox, :options]])
42
+ end
43
+ end
44
+ end
45
+ end
data/webaccount.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.author = 'thoran'
21
21
  spec.email = 'code@thoran.com'
22
- spec.homepage = 'http://github.com/thoran/WebAccount'
22
+ spec.homepage = 'https://github.com/thoran/webaccount'
23
23
  spec.license = 'MIT'
24
24
 
25
25
  spec.require_paths = ['lib']
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.files = [
29
29
  'CHANGELOG',
30
+ 'LICENSE',
30
31
  'Gemfile',
31
32
  Dir['lib/**/*.rb'],
32
33
  'Rakefile',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webaccount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -74,17 +74,19 @@ extra_rdoc_files: []
74
74
  files:
75
75
  - CHANGELOG
76
76
  - Gemfile
77
+ - LICENSE
77
78
  - README.md
78
79
  - Rakefile
79
80
  - lib/Thoran/Selenium.rb
80
81
  - lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb
81
82
  - lib/Thoran/Selenium/WebDriver/Driver/ElementPresentQ/element_presentQ.rb
82
- - lib/WebAccount/VERSION.rb
83
83
  - lib/web_account.rb
84
84
  - lib/webaccount.rb
85
+ - lib/webaccount/VERSION.rb
85
86
  - test/Thoran/Selenium/WebDriver/Driver/Attempt_test.rb
87
+ - test/webaccount_test.rb
86
88
  - webaccount.gemspec
87
- homepage: http://github.com/thoran/WebAccount
89
+ homepage: https://github.com/thoran/webaccount
88
90
  licenses:
89
91
  - MIT
90
92
  metadata: {}
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  requirements: []
105
- rubygems_version: 4.0.16
107
+ rubygems_version: 4.0.22
106
108
  specification_version: 4
107
109
  summary: An abstract super-class for navigating a web-based user account via Selenium
108
110
  WebDriver.