aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'features')
-rw-r--r--features/agenda.feature44
-rw-r--r--features/step_definitions/agenda_steps.rb15
-rw-r--r--features/step_definitions/user_steps.rb12
-rw-r--r--features/support/helper.rb15
4 files changed, 86 insertions, 0 deletions
diff --git a/features/agenda.feature b/features/agenda.feature
new file mode 100644
index 0000000..2969dc0
--- /dev/null
+++ b/features/agenda.feature
@@ -0,0 +1,44 @@
+Feature: Basic Agenda Creation
+ As a council member
+ I want to use the webapp to create agendas
+ in order to make my life easier
+
+ Background:
+ Given agenda "agenda_test_name" exists
+
+ Scenario: Guest operations
+ When I am on the home page
+ And I follow "Agendas"
+ And I follow "agenda_test_name"
+ Then I should see "agenda_test_name"
+ And I should not see "Edit Agenda"
+
+ Scenario: Council member creates agenda
+ Given I visit agendas as a council member
+ When I follow "New Agenda"
+ And I fill in "agenda_name" with "another_agenda_name"
+ And I press "Create Agenda"
+ Then I should see "created successfully"
+ When I go to the home page
+ And I follow "Agendas"
+ Then I should see "another_agenda_name"
+
+ Scenario: Council member edits agenda
+ Given I visit agendas as a council member
+ When I follow "agenda_test_name"
+ And I follow "Edit Agenda"
+ And I fill in "agenda_name" with "agenda_name_modified"
+ And I press "Save"
+ Then I should see "were saved"
+ When I go to the home page
+ And I follow "Agendas"
+ Then I should see "agenda_name_modified"
+
+ Scenario: Council member deletes agenda
+ Given I visit agendas as a council member
+ When I follow "agenda_test_name"
+ And I follow "Edit Agenda"
+ And I press "Remove This Agenda"
+ Then I should see "was deleted"
+ When I go to the home page
+ Then I should not see "agenda_modified"
diff --git a/features/step_definitions/agenda_steps.rb b/features/step_definitions/agenda_steps.rb
new file mode 100644
index 0000000..94a6248
--- /dev/null
+++ b/features/step_definitions/agenda_steps.rb
@@ -0,0 +1,15 @@
+# agenda creation testing is already covered in other steps.
+# let's speed up the test by directly modifying the Model
+Given /^agenda "([^\"]*)" exists$/ do |agenda_name|
+ @agenda = agendas(:agenda_one)
+ if @agenda.name != agenda_name
+ @agenda.update_attributes(:name => agenda_name)
+ end
+end
+
+# avoid repetition in agenda.features
+Given /^I visit agendas as a (.+)$/ do |user|
+ Given "I am logged in as a #{user}"
+ And 'I am on the home page'
+ When 'I follow "Agendas"'
+end
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb
new file mode 100644
index 0000000..1b4c321
--- /dev/null
+++ b/features/step_definitions/user_steps.rb
@@ -0,0 +1,12 @@
+Given /^I am a visitor$/ do
+ When 'I am on the home page'
+ Then 'I should not see "Logged in as"'
+end
+
+Given /^I am logged in as a (.+)$/ do |user|
+ @user = login_as(user.gsub(/\s/, '_').to_sym)
+ visit user_login_path
+ When %Q{I fill in "login" with "#{@user.email_address}"}
+ And 'I fill in "password" with "kktest3"'
+ And 'I press "Log in"'
+end
diff --git a/features/support/helper.rb b/features/support/helper.rb
new file mode 100644
index 0000000..f58b53d
--- /dev/null
+++ b/features/support/helper.rb
@@ -0,0 +1,15 @@
+# helper for feature test
+
+# helper method for user steps
+def login_as(role)
+ user = User.create!(
+ :name => 'kktest3',
+ :login => 'kktest3@kktest3.com',
+ :password => 'kktest3',
+ :password_confirmation => 'kktest3',
+ :role => :developer # will be ignored
+ )
+ user.role = role
+ user.save!
+ user
+end