Skip to content
Browse files

Cucumber self-tests; field_value returns string

  • Loading branch information...
1 parent 920de18 commit 585ecad652674af04d42c98ecb2473cf27365621 @wapcaplet committed May 12, 2011
Showing with 15 additions and 4 deletions.
  1. +10 −0 examples/sinatra_app/features/field.feature
  2. +2 −2 features/kelp_step_definitions.feature
  3. +3 −2 lib/kelp/field.rb
View
10 examples/sinatra_app/features/field.feature
@@ -20,6 +20,16 @@ Feature: Fields
| Message | Your message goes here |
+ Scenario: Field should contain
+ Then the "First name" field should contain ""
+ And the "Message" field should contain "Your message goes here"
+
+
+ Scenario: Field should not contain
+ When I fill in "First name" with "Adam"
+ Then the "First name" field should not contain "Jamie"
+
+
Scenario: Fill in single fields by label
When I fill in "First name" with "Adam"
And I fill in "Savage" for "Last name"
View
4 features/kelp_step_definitions.feature
@@ -68,8 +68,8 @@ Feature: Kelp Step Definitions
When I run cucumber on "field.feature"
Then the results should include:
"""
- 7 scenarios (7 passed)
- 30 steps (30 passed)
+ 9 scenarios (9 passed)
+ 36 steps (36 passed)
"""
Scenario: Field failure test
View
5 lib/kelp/field.rb
@@ -178,7 +178,8 @@ def field_should_be_empty(field, scope={})
end
- # Return the value found in the given field.
+ # Return the string value found in the given field.
+ # If the field is `nil`, return the empty string.
#
# @param [String] field
# Capybara locator for the field (name, id, or label text)
@@ -195,7 +196,7 @@ def field_value(field)
if value.class == Array
value = value.first
end
- return value
+ return value.to_s
end

0 comments on commit 585ecad

Please sign in to comment.
Something went wrong with that request. Please try again.