Method: Capybara::RackTest::Node#set

Defined in:
lib/capybara/rack_test/node.rb

#set(value, **options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/capybara/rack_test/node.rb', line 31

def set(value, **options)
  return if disabled? || readonly?

  warn "Options passed to Node#set but the RackTest driver doesn't support any - ignoring" unless options.empty?

  if value.is_a?(Array) && !multiple?
    raise TypeError, "Value cannot be an Array when 'multiple' attribute is not present. Not a #{value.class}"
  end

  if radio? then set_radio(value)
  elsif checkbox? then set_checkbox(value)
  elsif range? then set_range(value)
  elsif input_field? then set_input(value)
  elsif textarea? then native['_capybara_raw_value'] = value.to_s
  end
end