banker 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/banker.gemspec +3 -3
- data/lib/banker.rb +1 -0
- data/lib/banker/account.rb +8 -10
- data/lib/banker/barclaycard_uk.rb +13 -14
- data/lib/banker/barclays.rb +4 -15
- data/lib/banker/base.rb +34 -1
- data/lib/banker/capital_one_uk.rb +25 -24
- data/lib/banker/credit_expert_uk.rb +5 -30
- data/lib/banker/error.rb +7 -2
- data/lib/banker/transaction.rb +14 -0
- data/lib/banker/version.rb +1 -1
- data/spec/banker/account_spec.rb +8 -3
- data/spec/banker/barclaycard_uk_spec.rb +1 -0
- data/spec/banker/barclays_spec.rb +5 -1
- data/spec/banker/base_spec.rb +5 -0
- data/spec/banker/capital_one_uk_spec.rb +28 -27
- data/spec/banker/transaction_spec.rb +23 -0
- metadata +7 -5
data/banker.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require File.expand_path('../lib/banker/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ['Kyle Welsby'
|
6
|
-
gem.email = ['
|
7
|
-
gem.homepage = 'https://github.com/
|
5
|
+
gem.authors = ['Kyle Welsby']
|
6
|
+
gem.email = ['kyle@mekyle.com']
|
7
|
+
gem.homepage = 'https://github.com/kylewelsby/Banker'
|
8
8
|
gem.description = %q{A collection of strategies to access online bank accounts to obtain balance and transaction details.}
|
9
9
|
gem.summary = gem.description
|
10
10
|
|
data/lib/banker.rb
CHANGED
data/lib/banker/account.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
module Banker
|
2
|
-
class Account
|
3
|
-
attr_accessor :name, :uid, :amount, :limit, :currency
|
2
|
+
class Account < Base
|
3
|
+
attr_accessor :name, :uid, :amount, :limit, :currency, :transactions
|
4
4
|
def initialize(args = {})
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
@keys = %w(name uid amount)
|
6
|
+
params(args)
|
7
|
+
@transactions = []
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@limit = args[:limit]
|
13
|
-
@currency = args[:currency]
|
9
|
+
args.each do |attribute, value|
|
10
|
+
send(:"#{attribute}=", value)
|
11
|
+
end
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -13,9 +13,9 @@ module Banker
|
|
13
13
|
# bank.accounts.first.balance #=> 410010
|
14
14
|
#
|
15
15
|
class BarclaycardUK < Base
|
16
|
-
attr_accessor :username, :password, :memorable_word, :accounts, :page
|
16
|
+
attr_accessor :username, :password, :memorable_word, :accounts, :page, :ofx
|
17
17
|
|
18
|
-
LOGIN_ENDPOINT
|
18
|
+
LOGIN_ENDPOINT = 'https://bcol.barclaycard.co.uk/ecom/as2/initialLogon.do'
|
19
19
|
EXPORT_ENDPOINT = 'https://bcol.barclaycard.co.uk/ecom/as2/export.do?doAction=processRecentExportTransaction&type=OFX_2_0_2&statementDate=&sortBy=transactionDate&sortType=Dsc'
|
20
20
|
FIELDS = {
|
21
21
|
username: 'username',
|
@@ -38,12 +38,20 @@ module Banker
|
|
38
38
|
authenticate!
|
39
39
|
|
40
40
|
get_data
|
41
|
+
parse_ofx('credit_card')
|
41
42
|
end
|
42
43
|
private
|
43
44
|
|
44
45
|
def authenticate!
|
46
|
+
@agent = Mechanize.new
|
47
|
+
cookie = Mechanize::Cookie.new('LANDING_PAGE_COOKIE', '-D##')
|
48
|
+
u = URI.parse(LOGIN_ENDPOINT)
|
49
|
+
cookie.domain = ".barclaycard.co.uk"
|
50
|
+
cookie.path = "/"
|
51
|
+
@agent.cookie_jar.add(u, cookie)
|
45
52
|
page = get(LOGIN_ENDPOINT)
|
46
53
|
form = page.form_with(:action => '/ecom/as2/initialLogon.do')
|
54
|
+
raise FormMissing if form.nil?
|
47
55
|
|
48
56
|
form[FIELDS[:username]] = @username
|
49
57
|
form[FIELDS[:password]] = @password
|
@@ -72,18 +80,9 @@ module Banker
|
|
72
80
|
end
|
73
81
|
|
74
82
|
def get_data
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
OFX(ofx).credit_cards.each_with_object(@accounts) do |account, accounts|
|
79
|
-
args = { uid: Digest::MD5.hexdigest("Barclayard#{@username}#{account.id}"),
|
80
|
-
name: "Barclaycard #{account.id[-4,4]}",
|
81
|
-
amount: account.balance.amount_in_pennies,
|
82
|
-
currency: account.currency,
|
83
|
-
limit: @limit }
|
84
|
-
|
85
|
-
accounts << Banker::Account.new(args)
|
86
|
-
end
|
83
|
+
file = get(EXPORT_ENDPOINT)
|
84
|
+
body = file.body.gsub('VERSION="202"','VERSION="200"')
|
85
|
+
self.ofx = OFX(body)
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
data/lib/banker/barclays.rb
CHANGED
@@ -28,10 +28,11 @@ module Banker
|
|
28
28
|
@accounts = []
|
29
29
|
|
30
30
|
authenticate!
|
31
|
-
|
31
|
+
download!
|
32
|
+
parse_ofx
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
+
private
|
35
36
|
|
36
37
|
def authenticate!
|
37
38
|
page = get(LOGIN_URL)
|
@@ -72,19 +73,7 @@ module Banker
|
|
72
73
|
page = @agent.submit(form, form.buttons.first)
|
73
74
|
form = page.form_with(:action => "/olb/balances/ExportDataStep2All.action")
|
74
75
|
file = @agent.submit(form, form.buttons.last)
|
75
|
-
|
76
|
+
self.ofx = OFX(file.body)
|
76
77
|
end
|
77
|
-
|
78
|
-
def delivery(ofx)
|
79
|
-
ofx.bank_accounts.each_with_object(@accounts) do |account, accounts|
|
80
|
-
args = { uid: Digest::MD5.hexdigest("Barclays#{@membership_number}#{account.id}"),
|
81
|
-
name: "Barclays #{account.id[-4,4]}",
|
82
|
-
amount: account.balance.amount_in_pennies,
|
83
|
-
currency: account.currency }
|
84
|
-
|
85
|
-
accounts << Banker::Account.new(args)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
78
|
end
|
90
79
|
end
|
data/lib/banker/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Banker
|
2
2
|
class Base
|
3
|
-
attr_writer :keys
|
3
|
+
attr_writer :keys, :agent
|
4
4
|
def params(args)
|
5
5
|
missing_keys = []
|
6
6
|
return unless defined? @keys
|
@@ -18,9 +18,14 @@ module Banker
|
|
18
18
|
@agent.log = Logger.new 'banker.log'
|
19
19
|
@agent.user_agent = "Mozilla/5.0 (Banker)"
|
20
20
|
@agent.force_default_encoding = "utf8"
|
21
|
+
@agent.agent.http.ssl_version = :SSLv3
|
21
22
|
@agent.get(url)
|
22
23
|
end
|
23
24
|
|
25
|
+
def class_name
|
26
|
+
self.class.name.split("::").last
|
27
|
+
end
|
28
|
+
|
24
29
|
def get_letter(value,index)
|
25
30
|
value.to_s[index-1]
|
26
31
|
end
|
@@ -32,5 +37,33 @@ module Banker
|
|
32
37
|
def cleaner(str)
|
33
38
|
str.gsub(/[^\d+]/, '')
|
34
39
|
end
|
40
|
+
|
41
|
+
def parse_ofx(type='bank_account')
|
42
|
+
if type == 'credit_card'
|
43
|
+
_accounts = ofx.credit_cards
|
44
|
+
elsif type == 'bank_account'
|
45
|
+
_accounts = ofx.bank_accounts
|
46
|
+
end
|
47
|
+
_accounts.each_with_object(@accounts) do |account, accounts|
|
48
|
+
args = { uid: Digest::MD5.hexdigest("#{class_name}#{@membership_number}#{account.id}"),
|
49
|
+
name: "#{class_name} #{account.id[-4..-1]}",
|
50
|
+
amount: account.balance.amount_in_pennies,
|
51
|
+
currency: account.currency }
|
52
|
+
e_account = Banker::Account.new(args)
|
53
|
+
account.transactions.each do |transaction|
|
54
|
+
transaction_args = {
|
55
|
+
:amount => transaction.amount_in_pennies,
|
56
|
+
:description => transaction.name,
|
57
|
+
:transacted_at => transaction.posted_at,
|
58
|
+
:uid => transaction.fit_id,
|
59
|
+
:type => transaction.type
|
60
|
+
}
|
61
|
+
e_transaction = Banker::Transaction.new(transaction_args)
|
62
|
+
e_account.transactions << e_transaction
|
63
|
+
end
|
64
|
+
e_account.transactions.sort_by {|k,v| k.transacted_at}.reverse
|
65
|
+
accounts << e_account
|
66
|
+
end
|
67
|
+
end
|
35
68
|
end
|
36
69
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#coding: utf-8
|
1
2
|
module Banker
|
2
3
|
# This class allows the data retrieval of account balaces
|
3
4
|
# for Capital One UK
|
@@ -45,10 +46,7 @@ module Banker
|
|
45
46
|
|
46
47
|
form[FIELD[:username]] = @username
|
47
48
|
letters_html = page.at("#sign_in_box div:nth-child(3)").content
|
48
|
-
# return Banker::Error::Malformed, "Can't find split-password letters", caller if letters_html.nil?
|
49
|
-
|
50
49
|
letters = letters_html.scan(/(\d)/).collect { |letter| letter[0].to_i }
|
51
|
-
# return Banker::Error::Malformed, "Expected 3 letters, but get #{letters.size}", caller if letters.size != 3
|
52
50
|
|
53
51
|
form[FIELD[:password][0]] = get_letter(@password, letters[0])
|
54
52
|
form[FIELD[:password][1]] = get_letter(@password, letters[1])
|
@@ -57,10 +55,6 @@ module Banker
|
|
57
55
|
@page = @agent.submit(form, form.buttons.first)
|
58
56
|
end
|
59
57
|
|
60
|
-
#def letters
|
61
|
-
#html = page.search('#sign_in_box .password').content
|
62
|
-
#end
|
63
|
-
|
64
58
|
def get_data
|
65
59
|
limit = -@page.at("table[summary='account summary'] tr:nth-child(1) td.normalText:nth-child(2)").content.gsub(/\D/,'').to_i
|
66
60
|
amount = -@page.at("table[summary='account summary'] tr:nth-child(2) td.normalText:nth-child(2)").content.gsub(/\D/,'').to_i
|
@@ -68,23 +62,30 @@ module Banker
|
|
68
62
|
content.to_i
|
69
63
|
|
70
64
|
uid = Digest::MD5.hexdigest("CapitalOneUK#{account_number}")
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
65
|
+
last_four = account_number.to_s[-4..-1]
|
66
|
+
_account = Banker::Account.new(
|
67
|
+
:name => "Capital Account (#{last_four})",
|
68
|
+
:amount => amount,
|
69
|
+
:limit => limit,
|
70
|
+
:uid => uid,
|
71
|
+
:currency => "GBP"
|
72
|
+
)
|
73
|
+
|
74
|
+
form = page.form('DownLoadTransactionForm')
|
75
|
+
form.downloadType = 'csv'
|
76
|
+
csv_data = @agent.submit(form, form.buttons.first)
|
77
|
+
csv = csv_data.body.gsub(/,\s*/, ',')
|
78
|
+
_transactions = CSV.parse(csv, :headers => true)
|
79
|
+
_transactions.each do |transaction|
|
80
|
+
_transaction = Banker::Transaction.new(
|
81
|
+
:transacted_at => Time.parse(transaction[0]),
|
82
|
+
:amount => -transaction[2].gsub(/[^\d-]/,'').to_i,
|
83
|
+
:description => transaction[3],
|
84
|
+
:uid => transaction[7]
|
85
|
+
)
|
86
|
+
_account.transactions << _transaction
|
87
|
+
end
|
88
|
+
@accounts << _account
|
88
89
|
end
|
89
90
|
|
90
91
|
end
|
@@ -12,7 +12,7 @@ module Banker
|
|
12
12
|
#
|
13
13
|
# site.score #=> 800
|
14
14
|
#
|
15
|
-
class CreditExpertUK
|
15
|
+
class CreditExpertUK < Base
|
16
16
|
attr_accessor :username, :password, :memorable_word, :agent, :score
|
17
17
|
|
18
18
|
LOGIN_ENDPOINT = "https://www.creditexpert.co.uk/MCCLogin.aspx"
|
@@ -32,14 +32,12 @@ module Banker
|
|
32
32
|
}
|
33
33
|
|
34
34
|
def initialize(args)
|
35
|
+
@keys = %w(username password memorable_word)
|
36
|
+
params(args)
|
35
37
|
@username = args[:username]
|
36
38
|
@password = args[:password]
|
37
39
|
@memorable_word = args[:memorable_word]
|
38
40
|
|
39
|
-
@agent = Mechanize.new
|
40
|
-
@agent.log = Logger.new 'mech.log'
|
41
|
-
@agent.user_agent = 'Mozilla/5.0 (Banker)'
|
42
|
-
|
43
41
|
authenticate
|
44
42
|
end
|
45
43
|
|
@@ -47,34 +45,10 @@ module Banker
|
|
47
45
|
|
48
46
|
def authenticate
|
49
47
|
@score = data
|
50
|
-
=begin
|
51
|
-
page = @agent.get(LOGIN_ENDPOINT)
|
52
|
-
|
53
|
-
form = page.form_with(:action => 'MCCLogin.aspx')
|
54
|
-
|
55
|
-
form[FIELDS[:username]] = @username
|
56
|
-
form[FIELDS[:password]] = @password
|
57
|
-
|
58
|
-
|
59
|
-
page = @agent.submit(form, form.buttons.first)
|
60
|
-
|
61
|
-
form = page.form_with(:name => 'MasterPage')
|
62
|
-
|
63
|
-
first_letter = page.at(FIELDS[:questions][0]).content.scan(/\d+/).first.to_i
|
64
|
-
second_letter = page.at(FIELDS[:questions][1]).content.scan(/\d+/).first.to_i
|
65
|
-
|
66
|
-
form[FIELDS[:answers][0]] = get_letter(first_letter)
|
67
|
-
|
68
|
-
form[FIELDS[:answers][1]] = get_letter(second_letter)
|
69
|
-
|
70
|
-
page = @agent.submit(form, form.buttons.first)
|
71
|
-
|
72
|
-
@score = page.at(FIELDS[:score]).content.to_i
|
73
|
-
=end
|
74
48
|
end
|
75
49
|
|
76
50
|
def start
|
77
|
-
page =
|
51
|
+
page = get(LOGIN_ENDPOINT)
|
78
52
|
|
79
53
|
form = page.form_with(:action => 'MCCLogin.aspx')
|
80
54
|
|
@@ -87,6 +61,7 @@ module Banker
|
|
87
61
|
def step1
|
88
62
|
page = start
|
89
63
|
form = page.form_with(name: 'MasterPage')
|
64
|
+
raise MissingForm if form.nil?
|
90
65
|
|
91
66
|
first_letter = extract_digit(page.at(FIELDS[:questions][0]).content)
|
92
67
|
second_letter = extract_digit(page.at(FIELDS[:questions][1]).content)
|
data/lib/banker/error.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Banker
|
2
2
|
module Error
|
3
|
-
class
|
4
|
-
class
|
3
|
+
class BankerError < Exception; end
|
4
|
+
class InvalidParams < BankerError; end
|
5
|
+
class FormMissing < BankerError
|
6
|
+
def initialize(msg = "It appear that the form is missing. Please raise a GitHub issue https://github.com/kylewelsby/banker/issues")
|
7
|
+
super(msg)
|
8
|
+
end
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Banker
|
2
|
+
class Transaction < Base
|
3
|
+
attr_accessor :description, :amount, :transacted_at, :uid, :type
|
4
|
+
|
5
|
+
def initialize(args={})
|
6
|
+
@keys = %w{amount transacted_at}
|
7
|
+
params(args)
|
8
|
+
|
9
|
+
args.each do |attribute, value|
|
10
|
+
send(:"#{attribute}=", value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/banker/version.rb
CHANGED
data/spec/banker/account_spec.rb
CHANGED
@@ -13,20 +13,25 @@ describe Banker::Account do
|
|
13
13
|
it {subject.new(attr).should respond_to(:uid)}
|
14
14
|
it {subject.new(attr).should respond_to(:amount)}
|
15
15
|
it {subject.new(attr).should respond_to(:limit)}
|
16
|
+
it { expect(subject.new(attr)).to respond_to(:transactions) }
|
16
17
|
|
17
18
|
it "validates presence of name" do
|
18
19
|
expect{
|
19
20
|
subject.new
|
20
|
-
}.to raise_error(
|
21
|
+
}.to raise_error(Banker::Error::InvalidParams, %r{missing parameters `name` `uid` `amount`})
|
21
22
|
end
|
23
|
+
|
22
24
|
it "validates presence of uid" do
|
23
25
|
expect{
|
24
26
|
subject.new(name:'')
|
25
|
-
}.to raise_error(
|
27
|
+
}.to raise_error(Banker::Error::InvalidParams, %r{missing parameters `uid` `amount`})
|
26
28
|
end
|
29
|
+
|
27
30
|
it "validates presence of amount" do
|
28
31
|
expect{
|
29
32
|
subject.new(name:'',uid:'')
|
30
|
-
}.to raise_error(
|
33
|
+
}.to raise_error(Banker::Error::InvalidParams, %r{missing parameters `amount`})
|
31
34
|
end
|
35
|
+
|
36
|
+
it { expect(subject.new(attr).transactions).to be_a Array }
|
32
37
|
end
|
@@ -27,6 +27,7 @@ describe Banker::Barclays do
|
|
27
27
|
subject.any_instance.stub(:authenticate!)
|
28
28
|
subject.any_instance.stub(:download!)
|
29
29
|
subject.any_instance.stub(:delivery)
|
30
|
+
subject.any_instance.stub(:parse_ofx)
|
30
31
|
end
|
31
32
|
|
32
33
|
it { subject.new(args).should respond_to(:accounts) }
|
@@ -38,6 +39,7 @@ describe Banker::Barclays do
|
|
38
39
|
subject.any_instance.stub(:authenticate!)
|
39
40
|
subject.any_instance.stub(:download!)
|
40
41
|
subject.any_instance.stub(:delivery)
|
42
|
+
subject.any_instance.stub(:parse_ofx)
|
41
43
|
end
|
42
44
|
|
43
45
|
context 'Valid Params' do
|
@@ -63,6 +65,7 @@ describe Banker::Barclays do
|
|
63
65
|
subject.any_instance.stub(:authenticate!)
|
64
66
|
subject.any_instance.stub(:download!)
|
65
67
|
subject.any_instance.stub(:delivery)
|
68
|
+
subject.any_instance.stub(:parse_ofx)
|
66
69
|
end
|
67
70
|
|
68
71
|
it "should Call params Method" do
|
@@ -209,12 +212,13 @@ describe Banker::Barclays do
|
|
209
212
|
end
|
210
213
|
end
|
211
214
|
|
212
|
-
describe '#
|
215
|
+
describe '#get_data' do
|
213
216
|
let(:obj) { subject.new(args).accounts.first }
|
214
217
|
|
215
218
|
before do
|
216
219
|
subject.any_instance.stub(:authenticate!)
|
217
220
|
subject.any_instance.stub(:download!).and_return(ofx)
|
221
|
+
subject.any_instance.stub(:ofx).and_return(ofx)
|
218
222
|
end
|
219
223
|
|
220
224
|
it { obj.uid.should == '077db20dce9425514828c5104b10df51' }
|
data/spec/banker/base_spec.rb
CHANGED
@@ -18,10 +18,15 @@ describe Banker::Base do
|
|
18
18
|
Mechanize.should_receive(:new).and_return(mechanize)
|
19
19
|
Logger.should_receive(:new).and_return(logger)
|
20
20
|
|
21
|
+
agent = stub 'agent'
|
22
|
+
http = stub 'http'
|
21
23
|
mechanize.should_receive(:user_agent=).with("Mozilla/5.0 (Banker)")
|
22
24
|
mechanize.should_receive(:log=).with(logger)
|
23
25
|
mechanize.should_receive(:force_default_encoding=).with("utf8")
|
24
26
|
mechanize.should_receive(:get).with("http://google.com")
|
27
|
+
mechanize.should_receive(:agent).and_return(agent)
|
28
|
+
agent.should_receive(:http).and_return(http)
|
29
|
+
http.should_receive(:ssl_version=).with(:SSLv3)
|
25
30
|
|
26
31
|
subject.get("http://google.com")
|
27
32
|
end
|
@@ -103,32 +103,33 @@ describe Banker::CapitalOneUK do
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe "#get_data" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
end
|
106
|
+
# describe "#get_data" do
|
107
|
+
# before do
|
108
|
+
# subject.any_instance.stub(:get_letter)
|
109
|
+
|
110
|
+
# subject.any_instance.unstub(:authenticate!)
|
111
|
+
# subject.any_instance.unstub(:get_data)
|
112
|
+
# mechanize.should_receive(:submit).with("")
|
113
|
+
# end
|
114
|
+
|
115
|
+
# it "finds account balance" do
|
116
|
+
# mechanize.should_receive(:at).
|
117
|
+
# with("table[summary='account summary'] tr:nth-child(1) td.normalText:nth-child(2)").
|
118
|
+
# and_return(node)
|
119
|
+
# node.should_receive(:content).
|
120
|
+
# at_least(:once).
|
121
|
+
# and_return("£900.10")
|
122
|
+
# subject.new
|
123
|
+
# end
|
124
|
+
# it "finds account limit" do
|
125
|
+
# mechanize.should_receive(:at).
|
126
|
+
# with("table[summary='account summary'] tr:nth-child(2) td.normalText:nth-child(2)").
|
127
|
+
# and_return(node)
|
128
|
+
# node.should_receive(:content).
|
129
|
+
# at_least(:once).
|
130
|
+
# and_return("£950.50")
|
131
|
+
# subject.new
|
132
|
+
# end
|
133
|
+
# end
|
133
134
|
end
|
134
135
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Banker::Transaction do
|
4
|
+
let(:attr) {{
|
5
|
+
:amount => 1000,
|
6
|
+
:transacted_at => Time.now
|
7
|
+
}}
|
8
|
+
subject {Banker::Transaction}
|
9
|
+
|
10
|
+
it { expect(subject.new(attr)).to respond_to(:description) }
|
11
|
+
it { expect(subject.new(attr)).to respond_to(:amount) }
|
12
|
+
it { expect(subject.new(attr)).to respond_to(:transacted_at) }
|
13
|
+
it { expect(subject.new(attr)).to respond_to(:uid) }
|
14
|
+
it { expect(subject.new(attr)).to respond_to(:type) }
|
15
|
+
|
16
|
+
it "validates presence of amount" do
|
17
|
+
expect{ subject.new }.to raise_error(Banker::Error::InvalidParams, %r{amount})
|
18
|
+
end
|
19
|
+
|
20
|
+
it "validates presence of transacted_at" do
|
21
|
+
expect{ subject.new }.to raise_error(Banker::Error::InvalidParams, %r{transacted_at})
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kyle Welsby
|
9
|
-
- Chuck Hardy
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2012-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: mechanize
|
@@ -111,7 +110,7 @@ dependencies:
|
|
111
110
|
description: A collection of strategies to access online bank accounts to obtain balance
|
112
111
|
and transaction details.
|
113
112
|
email:
|
114
|
-
-
|
113
|
+
- kyle@mekyle.com
|
115
114
|
executables: []
|
116
115
|
extensions: []
|
117
116
|
extra_rdoc_files: []
|
@@ -134,6 +133,7 @@ files:
|
|
134
133
|
- lib/banker/credit_expert_uk.rb
|
135
134
|
- lib/banker/error.rb
|
136
135
|
- lib/banker/lloyds_tsb_uk.rb
|
136
|
+
- lib/banker/transaction.rb
|
137
137
|
- lib/banker/version.rb
|
138
138
|
- spec/banker/account_spec.rb
|
139
139
|
- spec/banker/barclaycard_uk_spec.rb
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- spec/banker/capital_one_uk_spec.rb
|
143
143
|
- spec/banker/credit_expert_uk_spec.rb
|
144
144
|
- spec/banker/lloyds_tsb_uk_spec.rb
|
145
|
+
- spec/banker/transaction_spec.rb
|
145
146
|
- spec/spec_helper.rb
|
146
147
|
- spec/support/barclaycard_uk/data.ofx
|
147
148
|
- spec/support/barclays/data.ofx
|
@@ -152,7 +153,7 @@ files:
|
|
152
153
|
- spec/support/lloyds_tsb_uk/entermemorableinformation.jsp.html
|
153
154
|
- spec/support/lloyds_tsb_uk/interstitialpage.jsp.html
|
154
155
|
- spec/support/lloyds_tsb_uk/login.jsp.html
|
155
|
-
homepage: https://github.com/
|
156
|
+
homepage: https://github.com/kylewelsby/Banker
|
156
157
|
licenses: []
|
157
158
|
post_install_message:
|
158
159
|
rdoc_options: []
|
@@ -185,6 +186,7 @@ test_files:
|
|
185
186
|
- spec/banker/capital_one_uk_spec.rb
|
186
187
|
- spec/banker/credit_expert_uk_spec.rb
|
187
188
|
- spec/banker/lloyds_tsb_uk_spec.rb
|
189
|
+
- spec/banker/transaction_spec.rb
|
188
190
|
- spec/spec_helper.rb
|
189
191
|
- spec/support/barclaycard_uk/data.ofx
|
190
192
|
- spec/support/barclays/data.ofx
|