Skip to content

Commit

Permalink
Added steps for validating the description & aim
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed Jul 21, 2009
1 parent ef3a34d commit e431638
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions 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
18 changes: 17 additions & 1 deletion features/registered_user.feature
Expand Up @@ -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
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'
15 changes: 13 additions & 2 deletions features/step_definitions/registered_user_steps.rb
Expand Up @@ -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

0 comments on commit e431638

Please sign in to comment.