lib/formulaic/inputs/string_input.rb in formulaic-0.0.3 vs lib/formulaic/inputs/string_input.rb in formulaic-0.0.4
- old
+ new
@@ -1,19 +1,27 @@
module Formulaic
module Inputs
class StringInput < Input
def fill
- if %w(text email password textarea).any? { |type| page.has_field?(input_text, type: type) }
+ if page.has_selector?(:fillable_field, input_text)
fill_in(input_text, with: value)
- elsif page.has_field?(input_text, type: 'radio')
+ elsif page.has_selector?(:radio_button, input_text)
choose(value)
- else
+ elsif has_option_in_select?(value, input_text)
select(value, from: input_text)
+ else
+ raise Formulaic::InputNotFound.new(%[Unable to find input "#{input_text}".])
end
end
def input_text
@input_text ||= input(model_name, field)
+ end
+
+ def has_option_in_select?(option, select)
+ find(:select, select).has_selector?(:option, option)
+ rescue Capybara::ElementNotFound
+ false
end
end
end
end