Class: Capybara::PageObject::UrlParser
- Inherits:
-
Object
- Object
- Capybara::PageObject::UrlParser
- Defined in:
- lib/capybara-pageobject/url_parser.rb
Instance Method Summary collapse
- #format(url_params) ⇒ Object
-
#initialize(url) ⇒ UrlParser
constructor
A new instance of UrlParser.
Constructor Details
#initialize(url) ⇒ UrlParser
Returns a new instance of UrlParser.
5 6 7 8 |
# File 'lib/capybara-pageobject/url_parser.rb', line 5 def initialize url raise 'url is not defined' if url.blank? @url = url.dup end |
Instance Method Details
#format(url_params) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/capybara-pageobject/url_parser.rb', line 10 def format url_params url_params.symbolize_keys! dynamic_params = parse_params(@url) raise "Please pass url parameters: #{dynamic_params}" unless url_params.keys.sort == dynamic_params.sort url_params.each_pair { |param, value| @url.gsub!(":#{param}", value.to_s) } @url end |