Class: Mbanker::Authenticator
- Inherits:
-
Object
- Object
- Mbanker::Authenticator
- Defined in:
- lib/mbanker/authenticator.rb
Instance Attribute Summary collapse
-
#crawler ⇒ Object
Returns the value of attribute crawler.
Instance Method Summary collapse
- #authenticate! ⇒ Object
- #authenticated? ⇒ Boolean
-
#initialize(crawler, login, password) ⇒ Authenticator
constructor
A new instance of Authenticator.
- #session_error_absent? ⇒ Boolean
- #unauthenticate! ⇒ Object
Constructor Details
#initialize(crawler, login, password) ⇒ Authenticator
Returns a new instance of Authenticator.
5 6 7 |
# File 'lib/mbanker/authenticator.rb', line 5 def initialize crawler, login, password @crawler, @login, @password = crawler, login, password end |
Instance Attribute Details
#crawler ⇒ Object
Returns the value of attribute crawler.
3 4 5 |
# File 'lib/mbanker/authenticator.rb', line 3 def crawler @crawler end |
Instance Method Details
#authenticate! ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mbanker/authenticator.rb', line 14 def authenticate! crawler.visit :login login_form = crawler.get_form login_form.customer = @login login_form.password = @password login_form.submit unless session_error_absent? raise "Could not authenticate" end end |
#authenticated? ⇒ Boolean
9 10 11 12 |
# File 'lib/mbanker/authenticator.rb', line 9 def authenticated? crawler.visit :accounts_list session_error_absent? end |
#session_error_absent? ⇒ Boolean
29 30 31 |
# File 'lib/mbanker/authenticator.rb', line 29 def session_error_absent? not crawler.can_find?('.error.noSession') end |
#unauthenticate! ⇒ Object
25 26 27 |
# File 'lib/mbanker/authenticator.rb', line 25 def unauthenticate! crawler.visit :logout end |