Module: Capybara::UI::Constructors

Included in:
Capybara::UI
Defined in:
lib/capybara/ui/widgets.rb

Instance Method Summary collapse

Instance Method Details

#Decimal(*selector) ⇒ Object


29
30
31
32
33
34
# File 'lib/capybara/ui/widgets.rb', line 29

def Decimal(*selector)
  Widget(selector) { |text|
    # ensure we can convert to float first
    Float(text) && BigDecimal.new(text)
  }
end

#Integer(*selector) ⇒ Object


23
24
25
# File 'lib/capybara/ui/widgets.rb', line 23

def Integer(*selector)
  Widget(selector) { |text| Kernel::Integer(text) }
end

#Widget(*selector, &block) ⇒ Object Also known as: String


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/capybara/ui/widgets.rb', line 9

def Widget(*selector, &block)
  if block_given?
    WidgetClass.new(selector.flatten) do
      define_method :value do
        block.call(text)
      end
    end
  else
    WidgetClass.new(selector.flatten)
  end
end