From e431638f6870d108db117154f0bfb77bf8baa266 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Tue, 21 Jul 2009 04:32:38 +0100 Subject: [PATCH] Added steps for validating the description & aim --- app/models/project.rb | 2 ++ features/registered_user.feature | 18 +++++++++++++++++- .../step_definitions/registered_user_steps.rb | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index f2e65e4..315e7ec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,3 +1,5 @@ class Project < ActiveRecord::Base validates_presence_of :title + validates_presence_of :description + validates_presence_of :aim end \ No newline at end of file diff --git a/features/registered_user.feature b/features/registered_user.feature index e954845..f995458 100644 --- a/features/registered_user.feature +++ b/features/registered_user.feature @@ -16,4 +16,20 @@ Feature: As a registered user I must be able to create projects And I click new project And fill in the new project form without a title And submit the form - Then a validation message will be displayed \ No newline at end of file + Then a validation message will be displayed say 'Title can't be blank' + + Scenario: When submitting the form the user must be alerted if the description is not present + Given an activated user logged in as 'reggie' + When I visit the home page + And I click new project + And fill in the new project form without a description + And submit the form + Then a validation message will be displayed say 'Description can't be blank' + + Scenario: When submitting the form the user must be alerted if the aim is not present + Given an activated user logged in as 'reggie' + When I visit the home page + And I click new project + And fill in the new project form without a aim + And submit the form + Then a validation message will be displayed say 'Aim can't be blank' \ No newline at end of file diff --git a/features/step_definitions/registered_user_steps.rb b/features/step_definitions/registered_user_steps.rb index 94b37ec..528b251 100644 --- a/features/step_definitions/registered_user_steps.rb +++ b/features/step_definitions/registered_user_steps.rb @@ -18,10 +18,21 @@ fill_in 'project_aim', :with => 'To provide a service' end +When /^fill in the new project form without a description$/ do + fill_in 'project_title', :with => 'new project' + fill_in 'project_aim', :with => 'To provide a service' +end + +When /^fill in the new project form without a aim$/ do + fill_in 'project_title', :with => 'new project' + fill_in 'project_description', :with => 'This project will help us manage stuff' +end + When /^submit the form$/ do submit_form 'new_project' end -Then /^a validation message will be displayed$/ do - response.should have_selector :li, :content => "Title can't be blank" +Then /^a validation message will be displayed say '(.*)'$/ do |message| + response.should have_selector :li, :content => message end +