Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cucumber self-tests; field_value returns string

  • Loading branch information...
commit 585ecad652674af04d42c98ecb2473cf27365621 1 parent 920de18
Eric Pierce authored
10 examples/sinatra_app/features/field.feature
@@ -20,6 +20,16 @@ Feature: Fields
20 20 | Message | Your message goes here |
21 21
22 22
  23 + Scenario: Field should contain
  24 + Then the "First name" field should contain ""
  25 + And the "Message" field should contain "Your message goes here"
  26 +
  27 +
  28 + Scenario: Field should not contain
  29 + When I fill in "First name" with "Adam"
  30 + Then the "First name" field should not contain "Jamie"
  31 +
  32 +
23 33 Scenario: Fill in single fields by label
24 34 When I fill in "First name" with "Adam"
25 35 And I fill in "Savage" for "Last name"
4 features/kelp_step_definitions.feature
@@ -68,8 +68,8 @@ Feature: Kelp Step Definitions
68 68 When I run cucumber on "field.feature"
69 69 Then the results should include:
70 70 """
71   - 7 scenarios (7 passed)
72   - 30 steps (30 passed)
  71 + 9 scenarios (9 passed)
  72 + 36 steps (36 passed)
73 73 """
74 74
75 75 Scenario: Field failure test
5 lib/kelp/field.rb
@@ -178,7 +178,8 @@ def field_should_be_empty(field, scope={})
178 178 end
179 179
180 180
181   - # Return the value found in the given field.
  181 + # Return the string value found in the given field.
  182 + # If the field is `nil`, return the empty string.
182 183 #
183 184 # @param [String] field
184 185 # Capybara locator for the field (name, id, or label text)
@@ -195,7 +196,7 @@ def field_value(field)
195 196 if value.class == Array
196 197 value = value.first
197 198 end
198   - return value
  199 + return value.to_s
199 200 end
200 201
201 202

0 comments on commit 585ecad

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