selenium - Dynamically create autoload command from filenames in Ruby -
i testing web application ruby, rspec, capybara , selenium , ran uninitialized constant activeadminloginpage
exception don't know how solve.
in spec_helper.rb requiring following:
dir[file.join(dir.pwd, 'spec/page_objects/**/*.rb')].each { |f| require f }
i have 2 classes
spec/page_objects/products/active_admin_login_page.rb module products class activeadminloginpage < ::activeadminloginpage ... end end
inherits from
spec/page_objects/active_admin_login_page.rb
unfortunately sub class loaded before parent class.
how create autoload command dynamically filenames in directory? replace command:
dir[file.join(dir.pwd, 'spec/page_objects/**/*.rb')].each { |f| require f }
with autoload command.
how use require
load dependency in file needs it?
require
loads file once, shouldn't encounter side effects.
or, better, can use auto_load
, uses require
under hood, in smarter way
autoload :activeadminloginpage, 'active_admin_login_page'
wiki
Comments
Post a Comment