Closed PanoramicPanda closed 5 years ago
My first thought on this one would be that the Page Class should probably match the capitalization on the gherkin, with the old version of the finder the case of all letters following the initial letter would be downcase, so something like
Given I visit the SOA Management Page
would require the pageclass to be named something like
class SoaManagementPage
end
This means that in the old finder, if i named the page SOAManagementPage
the finder would actually fail to get it.
Being that SOA is an acronym it would actually make sense for SOA to be capitalized in the page class name, in this case CA being an acronym would follow the same rules.
@greenarrowdb penny for your thoughts on this one?
I pondered this one a bit, and it occured to me, we have a full record of all pages defined in the router right? Why not just do something like:
def page_class_for(target_page)
@page_blueprints.keys.find{|it| it.to_s.downcase.include? target_page.gsub(' ','').downcase}
# or @page_blueprints.keys.find{|it| it.to_s.downcase.eql? "#{target_page.downcase.delete(' ')}page"}
end
Given /^I am on the (.*?) Page(?: by way of the (.*?) Page)?$/i do |target_page, intermediate_page|
@root_page.begin_new_session
proceed_to(@router.page_class_for(intemediate_page)) if intermediate_page
proceed_to(@router.page_class_for(target_page))
set_data_target
end
Honestly, there isn't really a case i can think of where we need something so broad as a constantize method (especially given it's part of a dynamic paradigm, replicating existing implementation in java for example would require reflection, nevermind the fact that searching packages with reflecting in java is actually easier than namespace searches in ruby.)
It would make more sense to maintain a registry of tested objects and reference that (eg. the router for web pages)
As an added benefit allows completely case insensitive page searching
133 causes a class mismatch if the step is not capitalized the exact same as the page class
And I proceed to the CA Eligibility Page
causes: