Module: CapybaraObjects::ScopedFinders

Extended by:
ActiveSupport::Concern
Included in:
ComponentObject, PageObject
Defined in:
lib/capybara_objects/scoped_finders.rb

Instance Method Summary collapse

Instance Method Details

#get_component(ctype, *args) ⇒ CapybaraObjects::ComponentObject

Fetch a component from within this component

Parameters:

  • ctype (String|Symbol)

    The component alias to find

  • args (Any)

    Any further arguments are passed on to the instance of the component

Returns:



12
13
14
15
16
17
# File 'lib/capybara_objects/scoped_finders.rb', line 12

def get_component(ctype, *args)
  registry.lookup_ctype(ctype).new(*args).tap do |comp|
    comp.scope = full_scope
    comp.validate!
  end
end

#root_nodeObject



19
20
21
22
23
# File 'lib/capybara_objects/scoped_finders.rb', line 19

def root_node
  within_parent_scope do
    find(*locator)
  end
end

#scoped_find(*args) ⇒ Capybara::Node

Finds a node within the scope of this component

Parameters:

  • args (Any)
    • All args get passed on to the normal capybara find method

Returns:

  • (Capybara::Node)

    The found node



28
29
30
31
32
# File 'lib/capybara_objects/scoped_finders.rb', line 28

def scoped_find(*args)
  within_my_scope do
    find(*args)
  end
end