Sha256: d60fb78c7786a5b42cb67383874c2120d7cd207335865005854d136c31b1f120
Contents?: true
Size: 908 Bytes
Versions: 3
Compression:
Stored size: 908 Bytes
Contents
module Screengem # # Singleton that gives the ability to get references to screen elements. # # On initialization generate a factory method for each screen element we can find. Example: # # def login_page # Pages::LoginPage.new # end # class ScreenElements include ::Singleton def initialize generated_method_names = [] Screengem::ScreenElement.descendants.each do |screen_element| class_name = screen_element.name method_name = class_name.demodulize.underscore if generated_method_names.include?(method_name) raise "Name collision: two screen elements resolve to '#{method_name}'." end generated_method_names << method_name class_eval(<<~RUBY, __FILE__, __LINE__ + 1) def #{method_name}(*args) #{class_name}.new(*args) end RUBY end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
screengem-0.6.0 | lib/screengem/screen_elements.rb |
screengem-0.5.0 | lib/screengem/screen_elements.rb |
screengem-0.4.0 | lib/screengem/screen_elements.rb |