Class: MineShaft::LoginPage
- Inherits:
-
Object
- Object
- MineShaft::LoginPage
- Defined in:
- lib/mine_shaft/login_page.rb
Overview
Collection of methods applicable to the login page, essentially simplifying the process of interacting with the login form for signing in.
Constant Summary collapse
- LOGIN_FORM_ACTION =
The relative URL for the login page on a Redmine site
'/login'
Class Method Summary collapse
-
.valid?(page) ⇒ Boolean
Public: Confirms whether the specified page is the Redmine login page or not.
Instance Method Summary collapse
-
#initialize(page) ⇒ LoginPage
constructor
Public: Instantiates a new LoginPage object.
-
#login_form ⇒ Object
Public: Retrieves the login form from the page.
Constructor Details
#initialize(page) ⇒ LoginPage
Public: Instantiates a new LoginPage object.
page - A Nokogiri::HTML::Document.
Returns a new instance of a LoginPage. Raises InvalidPage if the specified page does not contain the login form.
14 15 16 17 |
# File 'lib/mine_shaft/login_page.rb', line 14 def initialize(page) @page = page raise InvalidPage, "Page specified does not appear to be the login page" if !login_page? end |
Class Method Details
.valid?(page) ⇒ Boolean
Public: Confirms whether the specified page is the Redmine login page or
not.
page - A Nokogiri::HTML::Document.
Returns true if the specified page is the login page. Returns false if the specified page is not the login page.
26 27 28 29 30 31 32 33 |
# File 'lib/mine_shaft/login_page.rb', line 26 def self.valid?(page) begin new(page) return true rescue InvalidPage return false end end |
Instance Method Details
#login_form ⇒ Object
Public: Retrieves the login form from the page.
Returns an instance of the Mechanize::Form class.
38 39 40 |
# File 'lib/mine_shaft/login_page.rb', line 38 def login_form @login_form ||= @page.forms.find {|f| f.action.match(/#{LOGIN_FORM_ACTION}$/)} end |