Class: Napybara::FinderMethodsAppender

Inherits:
Object
  • Object
show all
Defined in:
lib/napybara/finder_methods_appender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, child_element_name, child_element_selector, optional_args, block) ⇒ FinderMethodsAppender

Returns a new instance of FinderMethodsAppender.



8
9
10
11
12
13
# File 'lib/napybara/finder_methods_appender.rb', line 8

def initialize(
  element, child_element_name, child_element_selector, optional_args, block)

  @element, @child_element_name, @child_element_selector, @optional_args, @block =
    element, child_element_name, child_element_selector, optional_args, block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'lib/napybara/finder_methods_appender.rb', line 5

def block
  @block
end

#child_element_nameObject (readonly)

Returns the value of attribute child_element_name.



5
6
7
# File 'lib/napybara/finder_methods_appender.rb', line 5

def child_element_name
  @child_element_name
end

#child_element_selectorObject (readonly)

Returns the value of attribute child_element_selector.



5
6
7
# File 'lib/napybara/finder_methods_appender.rb', line 5

def child_element_selector
  @child_element_selector
end

#elementObject (readonly)

Returns the value of attribute element.



5
6
7
# File 'lib/napybara/finder_methods_appender.rb', line 5

def element
  @element
end

#optional_argsObject (readonly)

Returns the value of attribute optional_args.



5
6
7
# File 'lib/napybara/finder_methods_appender.rb', line 5

def optional_args
  @optional_args
end

Instance Method Details

#capybara_optionsObject



22
23
24
25
26
27
# File 'lib/napybara/finder_methods_appender.rb', line 22

def capybara_options
  return {} if optional_args.empty?
  return {} if !optional_args.last.is_a?(Hash)

  optional_args.last
end

#executeObject



29
30
31
32
33
34
# File 'lib/napybara/finder_methods_appender.rb', line 29

def execute
  define_child_element_method
  define_has_child_element_method
  define_has_no_child_element_method
  define_child_elements_method
end

#record_selectorObject



15
16
17
18
19
20
# File 'lib/napybara/finder_methods_appender.rb', line 15

def record_selector
  return if optional_args.empty?
  return if !optional_args[0].is_a?(String)

  optional_args[0]
end