From 971d1d4a91fdb569f1f0c70bc85f8b613df58521 Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Mon, 9 May 2011 13:42:46 +0200 Subject: Add irc_nick field to User model --- site/features/irc_nick.feature | 20 ++++++++++++++++++ site/features/step_definitions/irc_nick_steps.rb | 26 ++++++++++++++++++++++++ site/features/step_definitions/login_steps.rb | 2 +- site/features/step_definitions/within_steps.rb | 10 +++++++++ site/features/support/paths.rb | 3 +++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 site/features/irc_nick.feature create mode 100644 site/features/step_definitions/irc_nick_steps.rb create mode 100644 site/features/step_definitions/within_steps.rb (limited to 'site/features') diff --git a/site/features/irc_nick.feature b/site/features/irc_nick.feature new file mode 100644 index 0000000..cb1d73a --- /dev/null +++ b/site/features/irc_nick.feature @@ -0,0 +1,20 @@ +Feature: IRC nick + In order to make IRC bot integration possible + I want all users to provide their freenode IRC nicks + + Scenario: User registration with nick + When I am on the homepage + And I follow "Signup" + And I signup as example user with IRC nick + Then I should see "Thanks for signing up!" in the notices + + Scenario: Fail user registration without nick + When I am on the signup page + And I signup as example user without IRC nick + Then I should see "Irc nick can't be blank" in the errors + And I should be on the signup page + + Scenario: View your own IRC nick + Given I am logged in as example user + When I follow "Logged in as Example" + Then I should see "example" as the user nick diff --git a/site/features/step_definitions/irc_nick_steps.rb b/site/features/step_definitions/irc_nick_steps.rb new file mode 100644 index 0000000..acaa4f8 --- /dev/null +++ b/site/features/step_definitions/irc_nick_steps.rb @@ -0,0 +1,26 @@ +When /^I fill in example user registration data$/ do + When "I fill in the following:", table(%{ + |user_name|examle| + |user_email_address|example@example.com| + |user_irc_nick|example| + |user_password|Example| + |user_password_confirmation|Example| + }) +end + +When /^I signup as example user without IRC nick$/ do + When 'I fill in example user registration data' + When 'I fill in "user_irc_nick" with ""' + When 'I press "Signup"' +end + +When /^I signup as example user with IRC nick$/ do + When 'I fill in example user registration data' + When 'I press "Signup"' +end + +Given /^I am logged in as example user$/ do + Given 'example user' + When 'I am on the login page' + When 'I login as example user' +end diff --git a/site/features/step_definitions/login_steps.rb b/site/features/step_definitions/login_steps.rb index 52fbcd3..5eaa5cc 100644 --- a/site/features/step_definitions/login_steps.rb +++ b/site/features/step_definitions/login_steps.rb @@ -1,6 +1,6 @@ Given /^example user$/ do user = User.new :name => "Example", :email_address => "example@example.com", - :password => "Example" + :password => "Example", :irc_nick => "example" user.save! end diff --git a/site/features/step_definitions/within_steps.rb b/site/features/step_definitions/within_steps.rb new file mode 100644 index 0000000..76b0ad6 --- /dev/null +++ b/site/features/step_definitions/within_steps.rb @@ -0,0 +1,10 @@ +{ + 'in the notices' => '.flash.notice', + 'in the errors' => '.error-messages', + 'as the user nick' => '.user-irc-nick' +}. +each do |within, selector| + Then /^I should( not)? see "([^"]*)" #{within}$/ do |negation, text| + Then %Q{I should#{negation} see "#{text}" within "#{selector}"} + end +end diff --git a/site/features/support/paths.rb b/site/features/support/paths.rb index 6ea5ce1..90b611b 100644 --- a/site/features/support/paths.rb +++ b/site/features/support/paths.rb @@ -14,6 +14,9 @@ module NavigationHelpers when /the login page/ user_login_path + when /the signup page/ + user_signup_path + # Add more mappings here. # Here is an example that pulls values out of the Regexp: # -- cgit v1.2.3-65-gdbad