Class: Chop::Form::AttachmentField
- Inherits:
-
Field
- Object
- Field
- Chop::Form::AttachmentField
- Defined in:
- lib/bard/attachment_field/cucumber.rb
Overview
Chop integration for form diffing and filling
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.css_selector ⇒ Object
119 120 121 |
# File 'lib/bard/attachment_field/cucumber.rb', line 119 def self.css_selector "input-attachment" end |
Instance Method Details
#diff_value ⇒ Object
131 132 133 |
# File 'lib/bard/attachment_field/cucumber.rb', line 131 def diff_value get_value.join(", ") end |
#fill_in! ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/bard/attachment_field/cucumber.rb', line 144 def fill_in! return if set_value.empty? file_paths = set_value.map do |filename| ::File.(::File.join(path, filename)).tap do |full_path| ::File.open(full_path) {} # raise Errno::ENOENT if file doesn't exist end end Bard::AttachmentField::TestHelper.attach_files(session, field[:id], file_paths) Bard::AttachmentField::TestHelper.wait_for_files(session, field[:id], file_paths.length) Bard::AttachmentField::TestHelper.wait_for_upload(session, field[:id]) end |
#get_value ⇒ Object
127 128 129 |
# File 'lib/bard/attachment_field/cucumber.rb', line 127 def get_value Bard::AttachmentField::TestHelper.get_files(field) end |
#matches? ⇒ Boolean
123 124 125 |
# File 'lib/bard/attachment_field/cucumber.rb', line 123 def matches? field.tag_name == "input-attachment" end |
#set_value ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/bard/attachment_field/cucumber.rb', line 135 def set_value filenames = if field[:multiple] value.to_s.split(", ").map(&:strip) else [value.to_s.strip] end filenames.reject(&:empty?) end |