Skip to content

Commit 33c6cfc

Browse files
author
Rhys Powell
committed
Finished implementing all the feature specs.
Finished writing the answers feature. All features now pass.
1 parent 6c57614 commit 33c6cfc

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

features/answers.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: CRUD actions for answers
2+
3+
As a user of the site, I can perform standard CRUD actions on answers
4+
5+
Scenario: Create an answer
6+
Given a question exists
7+
And I answer that question
8+
Then I should be notified that my answer was submitted
9+
And I should be able to see my answer
10+
11+
Scenario: Accept an answer
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Given /^a question exists$/ do
2+
login_user
3+
create_question_for(@user)
4+
end
5+
6+
Given /^I answer that question$/ do
7+
visit new_question_answer_path(@question)
8+
fill_in "Answer", with: "Have you tried turning it off and on again?"
9+
click_button "Post Answer"
10+
end
11+
12+
Then /^I should be notified that my answer was submitted$/ do
13+
page.should have_content("Answer Posted")
14+
end
15+
16+
Then /^I should be able to see my answer$/ do
17+
page.should have_content("#{@user.username} says")
18+
page.should have_content("Have you tried turning it off and on again?")
19+
end

features/step_definitions/question_steps.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
def create_question_for(user)
2+
@question = Question.new(:title => "A question",
3+
:description => "The description")
4+
@question.user = user
5+
@question.save
6+
end
7+
18
When /^I create a new question$/ do
29
step %{a logged in user}
310
visit new_question_path
@@ -18,14 +25,11 @@
1825

1926
Given /^I am a user that has created a question$/ do
2027
step %{a logged in user}
21-
@question = Question.new(:title => "A question",
22-
:description => "The description")
23-
@question.user = @user
24-
@question.save
28+
create_question_for(@user)
2529
end
2630

2731
When /^I edit that question$/ do
28-
visit "/questions/#{@question.id.to_s}/edit"
32+
visit edit_question_path(@question)
2933
fill_in "Title", with: "An edited question"
3034
fill_in "Description", with: "Just a quick edit"
3135
click_button "Ask Everyone"

0 commit comments

Comments
 (0)