webaccount 0.6.0 → 0.6.1

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: 6a94193d490acdd37702fbd4d09835e2a54ef201f5d214713e60bae26845c954
4
- data.tar.gz: 15aff8916367524214eb14a2979b3f9d7695557272f2fe44aa035a59aaccc12a
3
+ metadata.gz: 874519c62d687f06115a348e4e5b6dee2d351e5ebbc9be296c7365f95122e6b0
4
+ data.tar.gz: 196013753d9d54cdc05c180920f1d28f9328053c3c3db7977a7c2b6b7059f709
5
5
  SHA512:
6
- metadata.gz: 04a678d61437fba7d075eea20c1259786ecbfcb47d701305dac1ff8d362231be7f0a6c474a8497b5a3d8f86ec28e99d5a20267744d4bc32bdcf474322e09bc25
7
- data.tar.gz: 67e7b968e7fcab39c8696c087232cb0b020a60e049bfd5279d1a67653293a868553aac0c7cfc7f9ac05ecb4dc5b339d646c1d286dbb2271a6189bd5747a8ed8d
6
+ metadata.gz: a4741b9a5ace0a475145490628d6e664a5ac0c805ada36ffd10bebf49ddd0a75312c21afc8a6cfe7152ce2388f38fc50baaec9cb0a5ef5b29e92a8777b8cac9d
7
+ data.tar.gz: ba3085ac593bd153d894d9d20a2ca80051f3828f9f7333d06baf24152e21ef892daea5d6139bad6f5ce63d5dbdc80a8a0144ee6ff4b4fd4ebcfe149100b66b62
data/CHANGELOG CHANGED
@@ -1,5 +1,17 @@
1
1
  # webaccount/CHANGELOG
2
2
 
3
+ ## 20261103
4
+
5
+ 0.6.1: ~ WebAccount#shutdown quits the browser even where logging out fails.
6
+
7
+ A logout which raised, its button not found or the logged-out marker not appearing, left the browser open and still logged in.
8
+
9
+ 1. ~ WebAccount#shutdown(): driver.quit in an ensure.
10
+ 2. ~ test/webaccount_test.rb: + shutdown logs out then quits, quits where logging out raises, and doesn't log out where not logged in. The second fails against 0.6.0.
11
+ 3. ~ README.md: shutdown kills the session even if logging out fails.
12
+ 4. ~ VERSION: /0.6.0/0.6.1/
13
+
14
+
3
15
  ## 20261011
4
16
 
5
17
  0.6.0: + WebAccount#still_logged_in?, which says at once whether the page now showing still has the logout button.
data/README.md CHANGED
@@ -137,7 +137,7 @@ There are two, both overridable in a sub-class:
137
137
  my_account = MyAccount.new(username: username, password: password)
138
138
  my_account.login
139
139
  my_account.logout
140
- my_account.shutdown # If necessary it logs out and then kills the selenium session.
140
+ my_account.shutdown # If necessary it logs out, and then, even if logging out fails, kills the selenium session.
141
141
  ```
142
142
 
143
143
  ### Driving the browser once logged in
@@ -2,5 +2,5 @@
2
2
  # WebAccount::VERSION
3
3
 
4
4
  class WebAccount
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.1'
6
6
  end
data/lib/webaccount.rb CHANGED
@@ -51,8 +51,10 @@ class WebAccount
51
51
  end
52
52
  alias_method :logoff, :logout
53
53
 
54
+ # The browser is quit whether or not logging out succeeds, so as a failed logout doesn't leave a logged-in browser behind.
54
55
  def shutdown
55
56
  logout if logged_in?
57
+ ensure
56
58
  driver.quit
57
59
  end
58
60
 
@@ -43,6 +43,40 @@ describe WebAccount do
43
43
  end
44
44
  end
45
45
 
46
+ describe "#shutdown" do
47
+ def account_with_browser(logged_in:)
48
+ browser = Object.new
49
+ browser.define_singleton_method(:quit){@quit = true}
50
+ browser.define_singleton_method(:quit?){!!@quit}
51
+ account = WebAccount.new
52
+ account.instance_variable_set(:@driver, browser)
53
+ account.instance_variable_set(:@logged_in, logged_in)
54
+ [account, browser]
55
+ end
56
+
57
+ it "logs out, then quits the browser" do
58
+ account, browser = account_with_browser(logged_in: true)
59
+ account.define_singleton_method(:logout){@logged_out = true}
60
+ account.shutdown
61
+ _(account.instance_variable_get(:@logged_out)).must_equal(true)
62
+ _(browser.quit?).must_equal(true)
63
+ end
64
+
65
+ it "quits the browser even where logging out fails" do
66
+ account, browser = account_with_browser(logged_in: true)
67
+ account.define_singleton_method(:logout){raise Selenium::WebDriver::Error::TimeoutError}
68
+ _{account.shutdown}.must_raise(Selenium::WebDriver::Error::TimeoutError)
69
+ _(browser.quit?).must_equal(true)
70
+ end
71
+
72
+ it "doesn't log out where not logged in" do
73
+ account, browser = account_with_browser(logged_in: false)
74
+ account.define_singleton_method(:logout){raise 'logged out'}
75
+ account.shutdown
76
+ _(browser.quit?).must_equal(true)
77
+ end
78
+ end
79
+
46
80
  describe "#still_logged_in?" do
47
81
  def account_with_page(logout_button_present)
48
82
  page = Object.new
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 4.0.22
107
+ rubygems_version: 4.0.23
108
108
  specification_version: 4
109
109
  summary: An abstract super-class for navigating a web-based user account via Selenium
110
110
  WebDriver.