dinero 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: eb4017cc6f43d6883dd8eaea2c6adbda5825a2d5
4
- data.tar.gz: 76bf1dcc51b7a3a8bfa06a10f5caa4a5e758916c
3
+ metadata.gz: e13f6af47b55b1b155fe618af62c64fb1a5398de
4
+ data.tar.gz: f251a80a0fd2922e9cd592fb21d5cec4c0a0de93
5
5
  SHA512:
6
- metadata.gz: 46bcc34c6eefdadb0e6bd3b1a9b15ef49d4f1c94e33573b93ba62be90eb695d35f78948214535dc69125b4bbb0fd977340fea786ebf8c6be2fcf88bb70d32ef7
7
- data.tar.gz: a7ad3b30ba1ee06fb0ef0cb5eba40395ad83a12b2bdf9abb5586f376ed17d5f7593e255ca8e332c239c618bd9a23f74844124461df17edb6f5929635d502aeaa
6
+ metadata.gz: b3068eb926f3fe91839ca37eaeec32e0270b53540f0b08d57a776c562099196532b6ffc6f78913e9ee251ca9626f1e6cd2200d0d0310d27219bcedf5fd757bcd
7
+ data.tar.gz: dd5695fcc8227511d296462cb1edcadc239b0dece2f03c733436dad6e2bb730ba0784f2537145bc620efa130c2110b3140ff5bbc3abdefa6529b689c7a170cfc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dinero (0.0.5)
4
+ dinero (0.0.6)
5
5
  nokogiri (~> 1.6.6)
6
6
  selenium-webdriver (~> 3.0)
7
7
 
data/lib/dinero.rb CHANGED
@@ -9,6 +9,7 @@ require_relative 'dinero/banks/capital_one'
9
9
  require_relative 'dinero/banks/capital_one_360'
10
10
  require_relative 'dinero/banks/south_state_bank'
11
11
  require_relative 'dinero/banks/sdccu'
12
+ require_relative 'dinero/banks/georgias_own'
12
13
 
13
14
  # Models
14
15
  require_relative 'dinero/account'
data/lib/dinero/banks.rb CHANGED
@@ -28,9 +28,17 @@ module Dinero
28
28
  {}
29
29
  end
30
30
 
31
+ def find_answer question
32
+ if q = security_questions.detect{ |qa| qa["question"] == question }
33
+ return q["answer"]
34
+ else
35
+ raise "Unknown security question: #{question.inspect}"
36
+ end
37
+ end
38
+
31
39
  def establish_connection
32
40
  capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs(
33
- 'phantomjs.page.settings.userAgent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/33.0',
41
+ 'phantomjs.page.settings.userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:50.0) Gecko/20100101 Firefox/50.0',
34
42
  'service_args' => ['--ignore-ssl-errors=true', '--ssl-protocol=any']
35
43
  )
36
44
 
@@ -0,0 +1,99 @@
1
+ module Dinero
2
+ module Bank
3
+ # San Diego County Credit Union
4
+ class GeorgiasOwn < Base
5
+ LOGIN_URL = "https://www.georgiasown.org/index"
6
+ ACCOUNTS_SUMMARY_PATH = "https://online.georgiasown.org/DashboardV2"
7
+ CONNECTION_TIMEOUT = 20
8
+
9
+ def default_options
10
+ { timeout: CONNECTION_TIMEOUT, login_url: LOGIN_URL }
11
+ end
12
+
13
+ def post_username!
14
+ screenshot_on_error do
15
+ wait.until { connection.find_element(id: "login") }
16
+ login_area = connection.find_element(id: "login")
17
+
18
+ username_field = login_area.find_element(name: "UserName")
19
+ username_field.send_keys username
20
+
21
+ submit_button = login_area.find_element(xpath: ".//input[@type='submit']")
22
+ submit_button.click
23
+ end
24
+ end
25
+
26
+ def post_password!
27
+ screenshot_on_error do
28
+ wait.until { connection.find_element(id: "content") }
29
+ form = connection.find_element(id: "content")
30
+
31
+ password_field = form.find_element(id: "Password")
32
+ password_field.send_keys password
33
+
34
+ login_btn = form.find_element(xpath: ".//input[@type='submit']")
35
+ login_btn.click
36
+ end
37
+ end
38
+
39
+ def post_security_answer!
40
+ # return if on_accounts_summary_page?
41
+ # screenshot_on_error do
42
+ # wait.until { connection.find_element(id: "lblChallengeQuestion") }
43
+ # question_text = connection.find_element(id: "lblChallengeQuestion").text
44
+ # answer = find_answer question_text
45
+ #
46
+ # answer_field = connection.find_element(id: "QuestionAnswer")
47
+ # answer_field.send_keys answer
48
+ #
49
+ # submit_button = logon_form.find_element(id:"btnSubmitAnswer")
50
+ # submit_button.click
51
+ # end
52
+ end
53
+
54
+ def post_credentials!
55
+ post_username!
56
+ # post_security_answer!
57
+ post_password!
58
+ wait.until { connection.find_elements(xpath: "//div[@id='module_accounts']//ul/li").size > 0 }
59
+ end
60
+
61
+ def after_successful_login
62
+ # the subdomain frequently changes, so capture the actual URL
63
+ # so we can return to the page if necessary.
64
+ @accounts_summary_url = connection.current_url
65
+ end
66
+
67
+ def on_accounts_summary_page?
68
+ connection.page_source =~ /My Accounts/
69
+ end
70
+
71
+ def goto_accounts_summary_page
72
+ return if authenticated? && on_accounts_summary_page?
73
+ authenticated? ? connection.navigate.to(@accounts_summary_url) : login!
74
+ end
75
+
76
+ def account_table_rows
77
+ items = accounts_summary_document.xpath("//div[@id='module_accounts']//ul/li")
78
+ items.select{|s| s.attributes["data-is-external-account"]}
79
+ end
80
+
81
+ # extract account data from the account summary page
82
+ def accounts
83
+ return @accounts if @accounts
84
+
85
+ @accounts = account_table_rows.map do |row|
86
+ acct_type = :bank
87
+ name = row.xpath(".//h4").text
88
+ number = row.xpath(".//span[@class='account-number truncate']").text.strip
89
+
90
+ amount = row.xpath(".//span[@class='bal available']").text
91
+ balance = amount.strip.scan(NUMERIC_REGEXP).join
92
+ available = balance
93
+
94
+ Account.new(acct_type, name, number, balance, available)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -33,14 +33,6 @@ module Dinero
33
33
  end
34
34
  end
35
35
 
36
- def find_answer question
37
- if q = security_questions.detect{ |qa| qa["question"] == question }
38
- return q["answer"]
39
- else
40
- raise "Unknown security question: #{question.inspect}"
41
- end
42
- end
43
-
44
36
  def post_security_answer!
45
37
  return if on_accounts_summary_page?
46
38
  screenshot_on_error do
@@ -21,14 +21,6 @@ module Dinero
21
21
  end
22
22
  end
23
23
 
24
- def find_answer question
25
- if q = security_questions.detect{ |qa| qa["question"] == question }
26
- return q["answer"]
27
- else
28
- raise "Unknown security question: #{question.inspect}"
29
- end
30
- end
31
-
32
24
  def post_security_answer!
33
25
  screenshot_on_error do
34
26
  wait.until { connection.find_element(id: "nav2t") }
@@ -1,3 +1,3 @@
1
1
  module Dinero
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ if bank_configured? :georgias_own
4
+
5
+ RSpec.describe Dinero::Bank::GeorgiasOwn do
6
+ let(:bank_configuration) { bank_configurations[:georgias_own] }
7
+ let(:account_types) { bank_configuration[:account_types].sort }
8
+ let(:accounts) { bank_configuration[:accounts] }
9
+ let(:acct_name) { bank_configuration[:acct_name] }
10
+
11
+ before(:all) do
12
+ VCR.use_cassette("accounts_georgias_own", record: :new_episodes) do
13
+ @bank = Dinero::Bank::GeorgiasOwn.new(bank_configurations[:georgias_own])
14
+ @bank.accounts
15
+ end
16
+ end
17
+
18
+ it "has security questions" do
19
+ expect(@bank.security_questions.count).to eq 3
20
+ end
21
+
22
+ it "finds favorite hobby answer" do
23
+ expect(@bank.find_answer("What is your favorite hobby?")).to eq "tennis"
24
+ end
25
+
26
+ it "posts credentials" do
27
+ expect(@bank.authenticated?).to be true
28
+ end
29
+
30
+ it "authenticates" do
31
+ @bank.login!
32
+ expect(@bank.authenticated?).to eq true
33
+ end
34
+
35
+ it "handles security questions" do
36
+ pending "waiting for security questions to reappear to finish functionality!"
37
+ expect(true).to be false
38
+ end
39
+
40
+ it "retrieves accounts_summary_document" do
41
+ expect(@bank.accounts_summary_document).to be_kind_of Nokogiri::HTML::Document
42
+ end
43
+
44
+ it "has account_tables" do
45
+ expect(@bank.account_table_rows.size).to eq 2
46
+ end
47
+
48
+ it "gets expected accounts" do
49
+ expect(@bank.accounts.size).to eq accounts
50
+ end
51
+
52
+ it "extracts account names" do
53
+ expect(@bank.accounts.map(&:name)).to_not be_empty
54
+ end
55
+
56
+ it "extracts account numbers" do
57
+ expect(@bank.accounts.map(&:number).first).to start_with "800"
58
+ end
59
+
60
+ it "expects balances to be greater than zero" do
61
+ expect(@bank.accounts.first.balance.zero?).to eq true
62
+ end
63
+
64
+ it "expects availables to be greater than zero for bank accts" do
65
+ expect(@bank.accounts.first.balance.zero?).to eq true
66
+ end
67
+
68
+ it "sets account types" do
69
+ expect(@bank.accounts.map(&:account_type).uniq).to eq account_types
70
+ end
71
+ end
72
+
73
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dinero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -161,6 +161,7 @@ extra_rdoc_files: []
161
161
  files:
162
162
  - ".gitignore"
163
163
  - ".rspec"
164
+ - ".ruby-version"
164
165
  - Gemfile
165
166
  - Gemfile.lock
166
167
  - MIT-LICENSE
@@ -174,12 +175,14 @@ files:
174
175
  - lib/dinero/banks.rb
175
176
  - lib/dinero/banks/capital_one.rb
176
177
  - lib/dinero/banks/capital_one_360.rb
178
+ - lib/dinero/banks/georgias_own.rb
177
179
  - lib/dinero/banks/sdccu.rb
178
180
  - lib/dinero/banks/south_state_bank.rb
179
181
  - lib/dinero/version.rb
180
182
  - log/.keep
181
183
  - spec/banks/capital_one_360_spec.rb
182
184
  - spec/banks/capital_one_spec.rb
185
+ - spec/banks/georgias_own_spec.rb
183
186
  - spec/banks/sdccu_spec.rb
184
187
  - spec/banks/south_state_bank_spec.rb
185
188
  - spec/fixtures/vcr_cassettes/.keep
@@ -213,6 +216,7 @@ summary: Dinero automates the process of logging into banking and financial webs
213
216
  test_files:
214
217
  - spec/banks/capital_one_360_spec.rb
215
218
  - spec/banks/capital_one_spec.rb
219
+ - spec/banks/georgias_own_spec.rb
216
220
  - spec/banks/sdccu_spec.rb
217
221
  - spec/banks/south_state_bank_spec.rb
218
222
  - spec/fixtures/vcr_cassettes/.keep