Skip to content

Commit

Permalink
Adding textarea support to capybara field content assertion stepdef.
Browse files Browse the repository at this point in the history
  • Loading branch information
nruth committed Apr 29, 2010
1 parent 50992ea commit e5864f7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions templates/skeleton/step_definitions/capybara_steps.rb.erb
Expand Up @@ -142,7 +142,8 @@ end

Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
with_scope(selector) do
field_value = find_field(field).value
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should
field_value.should =~ /#{value}/
else
Expand All @@ -153,11 +154,12 @@ end

Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
with_scope(selector) do
field_value = find_field(field).value
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should_not
field_value.should_not =~ /#{value}/
else
assert_no_match(/#{value}/, field_value.value)
assert_no_match(/#{value}/, field_value)
end
end
end
Expand Down

0 comments on commit e5864f7

Please sign in to comment.