forked from NUBIC/surveyor
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at client side validation
Added required if question is marked as mandatory Also preliminary support for type checking (:float, :integer, :time) Using jqueryvalidation.org for client side validation NUBIC#34
- Loading branch information
Paul Friedman
committed
Aug 1, 2013
1 parent
98225cd
commit cc776ac
Showing
10 changed files
with
1,959 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Feature: Survey with validations | ||
As a survey participant | ||
I want to take a survey | ||
And be notified when I answer incorrectly | ||
|
||
# Issue 34 - client side validation for mandatory question | ||
@javascript | ||
Scenario: Creating a mandatory question | ||
Given I parse | ||
""" | ||
survey "Mandatory Question" do | ||
section "Required" do | ||
q "Type your name. This is required.", :is_mandatory => true | ||
a "name", :string | ||
end | ||
end | ||
""" | ||
When I start the "Mandatory Question" survey | ||
And I press "Click here to finish" | ||
Then I should see "This field is required." | ||
|
||
@javascript | ||
Scenario: Creating a question with an integer answer | ||
Given I parse | ||
""" | ||
survey "Integer Question" do | ||
section "How many" do | ||
q "How many pets do you own?" | ||
a "Number", :integer | ||
end | ||
end | ||
""" | ||
When I start the "Integer Question" survey | ||
And I fill in "Number" with "Eight" | ||
And I press "Click here to finish" | ||
Then I should see "A positive or negative non-decimal number please" | ||
|
||
@javascript | ||
Scenario: Creating a question with an float answer | ||
Given I parse | ||
""" | ||
survey "Float Question" do | ||
section "How many" do | ||
q "How mmuch oil do you use?" | ||
a "Quantity", :float | ||
end | ||
end | ||
""" | ||
When I start the "Float Question" survey | ||
And I fill in "Quantity" with "A lot" | ||
And I press "Click here to finish" | ||
Then I should see "Please enter a valid number." | ||
|
||
@javascript | ||
Scenario: Creating a question with a time answer | ||
Given I parse | ||
""" | ||
survey "Time Question" do | ||
section "When" do | ||
q "What time is it?" | ||
a "Time", :time | ||
end | ||
end | ||
""" | ||
When I start the "Time Question" survey | ||
And I press "When" | ||
And I fill in "Time" with "0900" | ||
When I press "Click here to finish" | ||
Then I should see "Please enter a valid time, between 00:00 and 23:59" |
Oops, something went wrong.