diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/step_definitions/categories_steps.rb | 3 | ||||
-rw-r--r-- | features/step_definitions/question_categories_steps.rb | 6 | ||||
-rw-r--r-- | features/step_definitions/questions_steps.rb | 4 | ||||
-rw-r--r-- | features/step_definitions/users_steps.rb | 10 |
4 files changed, 10 insertions, 13 deletions
diff --git a/features/step_definitions/categories_steps.rb b/features/step_definitions/categories_steps.rb new file mode 100644 index 0000000..66eee68 --- /dev/null +++ b/features/step_definitions/categories_steps.rb @@ -0,0 +1,3 @@ +Given /^a category "([^\"]*)"$/ do |name| + @category = Category.find_by_name(name) || Category.create!(:name => name) +end diff --git a/features/step_definitions/question_categories_steps.rb b/features/step_definitions/question_categories_steps.rb deleted file mode 100644 index e5d34e1..0000000 --- a/features/step_definitions/question_categories_steps.rb +++ /dev/null @@ -1,6 +0,0 @@ -Given /^a question category "([^\"]*)"$/ do |name| - @question_category = QuestionCategory.find_by_name(name) - if @question_category.nil? - @question_category = QuestionCategory.create!(:name => name) - end -end diff --git a/features/step_definitions/questions_steps.rb b/features/step_definitions/questions_steps.rb index fce0762..b0cd6fd 100644 --- a/features/step_definitions/questions_steps.rb +++ b/features/step_definitions/questions_steps.rb @@ -11,8 +11,8 @@ end Given /^a question "([^\"]*)" in category "([^\"]*)"$/ do |title, category| Given "a question \"#{title}\"" - Given "a question category \"#{category}\"" - @question.question_category = @question_category + Given "a category \"#{category}\"" + @question.category = @category @question.save! end diff --git a/features/step_definitions/users_steps.rb b/features/step_definitions/users_steps.rb index 932e538..9b66f29 100644 --- a/features/step_definitions/users_steps.rb +++ b/features/step_definitions/users_steps.rb @@ -14,9 +14,9 @@ end Given /^user "([^\"]*)" has category "([^\"]*)"$/ do |user_name, category_name| Given "user \"#{user_name}\"" - Given "a question category \"#{category_name}\"" - unless @user.question_categories.include?(@question_category) - @user.question_categories.push(@question_category) + Given "a category \"#{category_name}\"" + unless @user.categories.include?(@category) + @user.categories.push(@category) end @user.save! end @@ -30,8 +30,8 @@ Given /^"([^\"]*)" answered question "([^\"]*)"$/ do |user, question| end Given /^user "([^\"]*)" answered all questions in "([^\"]*)"$/ do |user_name, category_name| - Given "a question category \"#{category_name}\"" - for q in @question_category.questions + Given "a category \"#{category_name}\"" + for q in @category.questions if q.question_group.nil? Given "\"#{user_name}\" answered question \"#{q.title}\"" end |