Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Cucumber Step definitions for testing a form that uses jquery's validator plugin
# goes in features/step_definitions
Then /^I should see the "([^"]*)" error for "([^"]*)"$/ do |error, label|
field = find_field(label)
html_label = find("label[for=#{field[:id]}][class=error]")
html_label.text.should eql(error)
end
Then /^I should not see errors for "([^"]*)"$/ do |label|
field = find_field(label)
lambda {find("label[for=#{field[:id]}][class=error]")}.should raise_error(Capybara::ElementNotFound)
end
# example scenario testing a Change Password form
@javascript
Scenario: Change password with local validation errors
Given I am a new, authenticated user
When I go to the profile page
And I press "Update"
Then I should see the "This field is required." error for "user_password"
Then I should see the "This field is required." error for "user_password_confirmation"
Then I should see the "This field is required." error for "user_current_password"
And I fill in "user_password" with "123"
Then I should see the "Please enter at least 6 characters." error for "user_password"
And I fill in "user_password" with "123456"
And I fill in "user_password_confirmation" with "12346"
Then I should see the "Does not match your password" error for "user_password_confirmation"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.