cooler capybara
This commit is contained in:
parent
361c5c5714
commit
dba8d833c9
|
@ -1,8 +1,10 @@
|
||||||
def find_attribute(name)
|
def find_attribute(name, value = nil)
|
||||||
attribute = find("[data-field='#{name}']")
|
attribute = find("[data-field='#{name}']")
|
||||||
|
|
||||||
yield attribute, @inputs[name] if block_given?
|
yield attribute, @inputs[name] if block_given?
|
||||||
|
|
||||||
|
attribute.text.should == value if value
|
||||||
|
|
||||||
attribute
|
attribute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,10 +13,19 @@ def find_input(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_input(name, value)
|
def set_input(name, value)
|
||||||
|
value = value.id if value.respond_to?(:id)
|
||||||
|
|
||||||
@inputs ||= {}
|
@inputs ||= {}
|
||||||
@inputs[name] = value
|
@inputs[name] = value
|
||||||
|
|
||||||
find_input(name).set(value)
|
input = find_input(name)
|
||||||
|
|
||||||
|
case input.tag_name.downcase
|
||||||
|
when 'select'
|
||||||
|
input.find("option[value='#{value}']").select_option
|
||||||
|
else
|
||||||
|
input.set(value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_attributes(*attrs)
|
def find_attributes(*attrs)
|
||||||
|
|
Loading…
Reference in New Issue