module Wrapybara::FillableField

Public Instance Methods

empty?() click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 14
def empty?
        self.value == ''
end
fill_in(value) click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 3
def fill_in(value)
        self.should_exist
        # Capybara method
        @element.set(value)
end
has_content?(content) click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 26
def has_content?(content)
        self.value =~ /#{content}/
end
should_be_empty() click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 18
def should_be_empty
        raise UnmetExpectation, "Expected text field #{self.element_identifier} to be empty" unless self.empty?
end
should_have_content(content) click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 30
def should_have_content(content)
        if content.blank?
                self.should_be_empty
        else
                raise UnmetExpectation, "Expected text field #{self.element_identifier} to have content '#{content}'" unless self.has_content?(content)
        end
end
should_not_be_empty() click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 22
def should_not_be_empty
        raise UnmetExpectation, "Did not expect text field #{self.element_identifier} to be empty" if self.empty?
end
should_not_have_content(content) click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 38
def should_not_have_content(content)
        if content.blank?
                self.should_not_be_empty
        else
                raise UnmetExpectation, "Did not expect text field #{self.element_identifier} to have content '#{content}'" if self.has_content?(content)
        end
end
value() click to toggle source
# File lib/wrapybara/elements/fillable_field.rb, line 9
def value
        self.should_exist
        (@element.value || '').strip
end