File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+
18When /^I create a new question$/ do
29 step %{a logged in user}
310 visit new_question_path
1825
1926Given /^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 )
2529end
2630
2731When /^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"
You can’t perform that action at this time.
0 commit comments