Class: Pageify::PageObject
- Inherits:
-
Object
- Object
- Pageify::PageObject
- Extended by:
- RSpec::Matchers::DSL
- Defined in:
- lib/pageify/page_object.rb,
lib/pageify/capybara/base.rb,
lib/pageify/capybara/assertions.rb,
lib/pageify/capybara/bulk_actions.rb
Instance Attribute Summary collapse
-
#full_selector ⇒ Object
Returns the value of attribute full_selector.
-
#intend ⇒ Object
Returns the value of attribute intend.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#self_selector ⇒ Object
Returns the value of attribute self_selector.
Class Method Summary collapse
Instance Method Summary collapse
- #all(*args) ⇒ Object (also: #find_all)
- #click_on(child) ⇒ Object
- #createChild(raw_row) ⇒ Object
- #find(*args) ⇒ Object
- #first(*args) ⇒ Object
-
#initialize(name, self_selector, intend) ⇒ PageObject
constructor
A new instance of PageObject.
- #run_block(&block) ⇒ Object
- #selector ⇒ Object
- #set_fields(children_with_values_as_hash) ⇒ Object
- #should_have_disabled(fields) ⇒ Object
- #should_have_enabled(fields) ⇒ Object
- #should_match_fields(fields) ⇒ Object
- #should_not_have(fields) ⇒ Object
- #with_text(text) ⇒ Object
Constructor Details
#initialize(name, self_selector, intend) ⇒ PageObject
Returns a new instance of PageObject.
35 36 37 38 39 |
# File 'lib/pageify/page_object.rb', line 35 def initialize (name,self_selector,intend) @name = name @self_selector = self_selector @intend = intend end |
Instance Attribute Details
#full_selector ⇒ Object
Returns the value of attribute full_selector.
3 4 5 |
# File 'lib/pageify/page_object.rb', line 3 def full_selector @full_selector end |
#intend ⇒ Object
Returns the value of attribute intend.
3 4 5 |
# File 'lib/pageify/page_object.rb', line 3 def intend @intend end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/pageify/page_object.rb', line 3 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
3 4 5 |
# File 'lib/pageify/page_object.rb', line 3 def parent @parent end |
#self_selector ⇒ Object
Returns the value of attribute self_selector.
3 4 5 |
# File 'lib/pageify/page_object.rb', line 3 def self_selector @self_selector end |
Class Method Details
.create(raw_row) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/pageify/page_object.rb', line 24 def self.create (raw_row) name = raw_row.lstrip.split(":").first self_selector = raw_row.slice(raw_row.index(':')+1..-1) intend = raw_row.lspace PageObject.new(name,self_selector,intend) end |
Instance Method Details
#all(*args) ⇒ Object Also known as: find_all
25 26 27 |
# File 'lib/pageify/capybara/base.rb', line 25 def all(*args) page.all(selector,*args) end |
#click_on(child) ⇒ Object
27 28 29 30 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 27 def click_on child get_child(child).find.click self end |
#createChild(raw_row) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pageify/page_object.rb', line 5 def createChild (raw_row) child = PageObject.create(raw_row) child.parent = self define_singleton_method(child.name) do |*arguments| unless arguments.eql? [] child_selector = (child.self_selector % arguments).strip_quotes.strip else child_selector = (child.self_selector % '').strip_quotes.strip end if child_selector.start_with? "&" child.full_selector = @full_selector + child_selector.gsub(/^&/, "") else child.full_selector = @full_selector + " " + child_selector end child end return child end |
#find(*args) ⇒ Object
14 15 16 |
# File 'lib/pageify/capybara/base.rb', line 14 def find(*args) get_session.find(selector,*args) end |
#first(*args) ⇒ Object
31 32 33 |
# File 'lib/pageify/capybara/base.rb', line 31 def first(*args) page.first(selector,*args) end |
#run_block(&block) ⇒ Object
41 42 43 44 |
# File 'lib/pageify/page_object.rb', line 41 def run_block (&block) @self_before_instance_eval = eval "self", block.binding instance_eval &block end |
#selector ⇒ Object
31 32 33 |
# File 'lib/pageify/page_object.rb', line 31 def selector @full_selector.strip end |
#set_fields(children_with_values_as_hash) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 32 def set_fields children_with_values_as_hash children_with_values_as_hash.each do |key,value| get_child(key).set value end self end |
#should_have_disabled(fields) ⇒ Object
19 20 21 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 19 def should_have_disabled fields process_fields(fields,Proc.new{|field| get_child(field).find.should be_disabled}) end |
#should_have_enabled(fields) ⇒ Object
15 16 17 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 15 def should_have_enabled fields process_fields(fields,Proc.new{|field| get_child(field).find.should be_enabled}) end |
#should_match_fields(fields) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 5 def should_match_fields fields if fields.is_a?(Hash) match_fields fields else fields.hashes.each do |field| match_fields field end end end |
#should_not_have(fields) ⇒ Object
23 24 25 |
# File 'lib/pageify/capybara/bulk_actions.rb', line 23 def should_not_have fields process_fields(fields,Proc.new{|field|page.should_not have_css get_selector(field)}) end |
#with_text(text) ⇒ Object
35 36 37 |
# File 'lib/pageify/capybara/base.rb', line 35 def with_text(text) page.find(selector,:text=>text) end |