webaccount 0.5.0 → 0.6.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: 90b5b4da3fa0eee7ac4a4c6c85ce3b59a7640bc7aaff8065b7c8432920d8a255
4
- data.tar.gz: 1a5efd14b2d09b0dd2d6eeaef4128272d7e34e18779e62cf968a95455858ee1a
3
+ metadata.gz: 6a94193d490acdd37702fbd4d09835e2a54ef201f5d214713e60bae26845c954
4
+ data.tar.gz: 15aff8916367524214eb14a2979b3f9d7695557272f2fe44aa035a59aaccc12a
5
5
  SHA512:
6
- metadata.gz: dbf5f58ce0a99f2232796010962a20f39b45a55e8ba0c5c414b2c3c50ea3c8f54fe409ab4b36878d36a5cf849664b187c3119bc3a79e483c50c2e2196f3b55a8
7
- data.tar.gz: 935406e37e640aafd799a60a422314282874d0ffc5369fe398dde3b0948987da01583fc649ffdb47ebf58c421c0881fcf2a00dbeabeb5595ad1e92cac890b37c
6
+ metadata.gz: 04a678d61437fba7d075eea20c1259786ecbfcb47d701305dac1ff8d362231be7f0a6c474a8497b5a3d8f86ec28e99d5a20267744d4bc32bdcf474322e09bc25
7
+ data.tar.gz: 67e7b968e7fcab39c8696c087232cb0b020a60e049bfd5279d1a67653293a868553aac0c7cfc7f9ac05ecb4dc5b339d646c1d286dbb2271a6189bd5747a8ed8d
data/CHANGELOG CHANGED
@@ -1,7 +1,17 @@
1
- # CHANGELOG
1
+ # webaccount/CHANGELOG
2
2
 
3
3
  ## 20261011
4
4
 
5
+ 0.6.0: + WebAccount#still_logged_in?, which says at once whether the page now showing still has the logout button.
6
+
7
+ logged_in? answers from what login() found, and is not told when a session expires afterwards; logged_out? waits up to default_wait_timeout, 30s, for the logged-out marker, which is too long to ask of every page. Something driving the browser from page to page, as 0.5.0 lets it, had no quick way to notice that the session had ended underneath it.
8
+
9
+ 1. + WebAccount#still_logged_in?(): whether the logout button is on the page now showing, by element_present?, which does not wait; and logged_in? is brought into line with the answer.
10
+ 2. ~ test/webaccount_test.rb: + true and false with logged_in? following, and a single look rather than a wait, with a stand-in for the browser. All three fail against 0.5.0.
11
+ 3. ~ README.md: + still_logged_in?, under Driving the browser once logged in; /WebAccount\/fork/webaccount\/fork/ in Contributing, the repository having been renamed webaccount.
12
+ 4. ~ CHANGELOG: /# CHANGELOG/# webaccount\/CHANGELOG/, after the repository.
13
+ 5. ~ VERSION: /0.5.0/0.6.0/
14
+
5
15
  0.5.0: + WebAccount#driver, public, so that the logged-in browser can be driven from outside.
6
16
 
7
17
  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.
data/README.md CHANGED
@@ -152,6 +152,12 @@ There are two, both overridable in a sub-class:
152
152
  my_account.shutdown
153
153
  ```
154
154
 
155
+ `still_logged_in?` says whether the page now showing still has the logout button, at once rather than after waiting, so that something moving from page to page can tell when the session has ended, and log in again:
156
+ ```ruby
157
+ my_account.driver.get(url)
158
+ my_account.login unless my_account.still_logged_in?
159
+ ```
160
+
155
161
  ### Overriding the login method to customise logins
156
162
  ```ruby
157
163
  require 'webaccount'
@@ -186,7 +192,7 @@ Prefer `find` over `driver.find_element`: it waits up to `default_find_timeout`
186
192
 
187
193
  ## Contributing
188
194
 
189
- 1. Fork it: https://github.com/thoran/WebAccount/fork
195
+ 1. Fork it: https://github.com/thoran/webaccount/fork
190
196
  2. Create your feature branch: `git checkout -b my-new-feature`
191
197
  3. Commit your changes: `git commit -am 'Add some feature'`
192
198
  4. Push to the branch: `git push origin my-new-feature`
@@ -2,5 +2,5 @@
2
2
  # WebAccount::VERSION
3
3
 
4
4
  class WebAccount
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
data/lib/webaccount.rb CHANGED
@@ -72,6 +72,10 @@ class WebAccount
72
72
  end
73
73
  end
74
74
 
75
+ def still_logged_in?
76
+ @logged_in = driver.element_present?(logout_button_selector.keys.first, logout_button_selector.values.first)
77
+ end
78
+
75
79
  private
76
80
 
77
81
  # driver construction
@@ -42,4 +42,35 @@ describe WebAccount do
42
42
  end
43
43
  end
44
44
  end
45
+
46
+ describe "#still_logged_in?" do
47
+ def account_with_page(logout_button_present)
48
+ page = Object.new
49
+ page.define_singleton_method(:element_present?){|how, what| (@asked ||= []) << [how, what]; logout_button_present}
50
+ page.define_singleton_method(:asked){@asked}
51
+ account = WebAccount.new(logout_button_selector: {css: '#logout'})
52
+ account.instance_variable_set(:@driver, page)
53
+ [account, page]
54
+ end
55
+
56
+ it "is true, and makes logged_in? true, where the page has the logout button" do
57
+ account, page = account_with_page(true)
58
+ _(account.still_logged_in?).must_equal(true)
59
+ _(account.logged_in?).must_equal(true)
60
+ _(page.asked).must_equal([[:css, '#logout']])
61
+ end
62
+
63
+ it "is false, and makes logged_in? false, where the page has not" do
64
+ account, _page = account_with_page(false)
65
+ account.instance_variable_set(:@logged_in, true)
66
+ _(account.still_logged_in?).must_equal(false)
67
+ _(account.logged_in?).must_equal(false)
68
+ end
69
+
70
+ it "asks once rather than waiting for the button to appear" do
71
+ account, page = account_with_page(false)
72
+ account.still_logged_in?
73
+ _(page.asked.length).must_equal(1)
74
+ end
75
+ end
45
76
  end
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran