Logo: Relish

  1. Sign in

Project: Lombard

LOM8.4 Hard Server Side Validations

User tries to save form
In order to make sure my data is correct
As a user filling out the form
I want the form to check for correct ranges

Background
Given
the survey
survey "Ranges" do
  section "Section One" do
  label "Float Ranges"

  q_1 "tall are you?", :is_mandatory => true
    answer "height", :float
    validation :rule => "A"
    condition_A ">=", :float_value => 24.5

  q_2 "how many fingers do you have?", :is_mandatory => true
    answer "fingers", :float
    validation :rule => "A", :message => "Cannot have more than ten fingers"
    condition_A "<=", :float_value => 10.0

  q_3 "what is your weight?", :is_mandatory => true
    answer "weight", :float
    validation :rule => "A and B", :message => "Must be in range"
    condition_A "<=", :float_value => 450.5
    condition_B ">=", :float_value => 1.5
  end
end
Given
I am signed in as a clinician
And
I start the "Ranges" survey
Scenarios
  • @javascript
All float values within ranges
When
I fill in and change "height" with "30.5"
And
I fill in and change "fingers" with "9.5"
And
I fill in and change "weight" with "200.8"
Then
I should not see an inline error
When
I press "Click here to finish"
Then
the survey should now be complete
And
I should be on the surveys page
And
I should not see "Unable to update survey"
  • @javascript
All float values out of ranges
When
I fill in and change "height" with "12.2"
Then
I should see an inline error
And
I fill in and change "fingers" with "14.5"
Then
I should see the inline error "Cannot have more than ten fingers"
And
I fill in and change "weight" with "500.4"
Then
I should see the inline error "Must be in range"
And
I press "Click here to finish"
Then
the survey is not complete
And
I should be on the "Ranges" survey page
And
I should see "Unable to update survey" within the error flash

Last published over 5 years ago by wminsinger.