Permalink
Browse files

Keeping up with Yodlee changes

  • Loading branch information...
1 parent 96c8376 commit b9c0b85c91ee8e9cde65aed892b73ad2fbd1752d @aasmith committed Sep 25, 2009
Showing with 11 additions and 14 deletions.
  1. +5 −9 lib/yodlee/connection.rb
  2. +6 −5 test/test_yodlee.rb
@@ -10,16 +10,15 @@ def initialize(credentials, logger = nil)
@agent = WWW::Mechanize.new
@agent.user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5'
- @uris = {}
+ @accounts_page = nil
end
def accounts
return @accounts if @accounts
handle_connection!
-
- page = @agent.get(@uris[:accounts])
- doc = Nokogiri::HTML.parse(page.body)
+
+ doc = Nokogiri::HTML.parse(@accounts_page.body)
@accounts = doc.search(".acctbean a").map{|e|
acct = Account.new(self)
@@ -38,7 +37,7 @@ def accounts
end
def account_info(acct)
- page = @agent.get(@uris[:accounts])
+ page = @accounts_page
link = page.links.detect{|lnk| lnk.href =~ /itemAccountId=#{acct.id}/ } or raise AccountNotFound, "Could not find account in list"
link.href << "&dateRangeId=-1"
@@ -288,11 +287,8 @@ def provide_password(page)
# ack javascript disabled
f = page.form_with(:name => 'updateForm')
- page = @agent.submit(f)
-
- link = page.links.detect { |lnk| lnk.attributes["id"] == "ACCOUNT_BALANCE" }
- @uris[:accounts] = link.href.to_s << "&filter_id=-1"
+ @accounts_page = @agent.submit(f)
end
end
end
View
@@ -123,14 +123,15 @@ def test_accounts
mock = flexmock(@conn)
inject_agent(agent = flexmock("mechanize"))
- mock.should_receive(:handle_connection!).once
- agent.should_receive(:get).once.and_return(
- flexmock(:body => "
- <div class='acctbean'>
+ page = flexmock
+ page.should_receive(:body).and_return(
+ "<div class='acctbean'>
<a href='u?itemId=1&itemAccountId=2'><strong>x</strong> - y</a>
<a href='u?itemId=8&itemAccountId=9'><strong>a</strong> - b</a>
</div>")
- )
+
+ mock.should_receive(:handle_connection!).once
+ mock.instance_variable_set "@accounts_page", page
assert_equal "x", @conn.accounts.first.institute_name
assert_equal "y", @conn.accounts.first.name

0 comments on commit b9c0b85

Please sign in to comment.