Skip to content

Commit

Permalink
Fixed new line bug from Capybara
Browse files Browse the repository at this point in the history
  • Loading branch information
ben2d2 committed Nov 8, 2012
1 parent 95fad30 commit 605ddce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions features/step_definitions/interaction_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

Then /^I should see "(.*?)" in the "(.*?)" field$/ do |text, field_name|
field = find_field(field_name)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
field_value.to_s.should == text.to_s
# Rails adds a line break to beginning of textarea tags
# https://github.com/rails/rails/issues/393
# Capybara does not remove the line break
# https://github.com/jnicklas/capybara/issues/677
# We are fixing it locally by removing the first character
field_value = (field.tag_name == 'textarea') ? field.text[1..-1] || "" : field.value

This comment has been minimized.

Copy link
@elizabrock

elizabrock Nov 13, 2012

Member

field_value.strip would accomplish the (or lstrip) would accomplish the same thing and be a little clearer.

field_value.should == text
end

0 comments on commit 605ddce

Please sign in to comment.