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 +4 -4
- data/CHANGELOG +11 -1
- data/README.md +7 -1
- data/lib/webaccount/VERSION.rb +1 -1
- data/lib/webaccount.rb +4 -0
- data/test/webaccount_test.rb +31 -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: 6a94193d490acdd37702fbd4d09835e2a54ef201f5d214713e60bae26845c954
|
|
4
|
+
data.tar.gz: 15aff8916367524214eb14a2979b3f9d7695557272f2fe44aa035a59aaccc12a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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/
|
|
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`
|
data/lib/webaccount/VERSION.rb
CHANGED
data/lib/webaccount.rb
CHANGED
data/test/webaccount_test.rb
CHANGED
|
@@ -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
|