Module: Wrapybara::FillableField
- Included in:
- PasswordField, TextArea, TextField
- Defined in:
- lib/wrapybara/elements/fillable_field.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #fill_in(value) ⇒ Object
- #has_content?(content) ⇒ Boolean
- #should_be_empty ⇒ Object
- #should_have_content(content) ⇒ Object
- #should_not_be_empty ⇒ Object
- #should_not_have_content(content) ⇒ Object
- #value ⇒ Object
Instance Method Details
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/wrapybara/elements/fillable_field.rb', line 14 def empty? self.value == '' end |
#fill_in(value) ⇒ Object
3 4 5 6 7 |
# 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) ⇒ Boolean
26 27 28 |
# File 'lib/wrapybara/elements/fillable_field.rb', line 26 def has_content?(content) self.value =~ /#{content}/ end |
#should_be_empty ⇒ Object
18 19 20 |
# 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) ⇒ Object
30 31 32 33 34 35 36 |
# 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 ⇒ Object
22 23 24 |
# 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) ⇒ Object
38 39 40 41 42 43 44 |
# 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 ⇒ Object
9 10 11 12 |
# File 'lib/wrapybara/elements/fillable_field.rb', line 9 def value self.should_exist (@element.value || '').strip end |