Skip to content

Commit

Permalink
Passing questions feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhys Powell committed Nov 23, 2011
1 parent d3a966b commit 31f728c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
14 changes: 14 additions & 0 deletions features/questions.feature
@@ -0,0 +1,14 @@
Feature: CRUD actions for question

As a user of the site, I can perform standard CRUD actions on questions

Scenario: Create a question
When I create a new question
Then I should be told the question was created
And I should be able to see the new question

Scenario: Update a question
Given I am a user that has created a question
When I edit that question
Then I should be told the question was updated
And I should see that the question was updated
41 changes: 41 additions & 0 deletions features/step_definitions/question_steps.rb
@@ -0,0 +1,41 @@
When /^I create a new question$/ do
step %{a logged in user}
visit new_question_path
fill_in("Title", with: "My Question")
fill_in("Description", with: "My Description")
click_button "Ask Everyone"
end

Then /^I should be told the question was created$/ do
page.should have_content("Question Asked")
end

Then /^I should be able to see the new question$/ do
click_link("My Question")
page.should have_content("My Question")
page.should have_content("My Description")
end

Given /^I am a user that has created a question$/ do
step %{a logged in user}
@question = Question.new(:title => "A question",
:description => "The description")
@question.user = @user
@question.save
end

When /^I edit that question$/ do
visit "/questions/#{@question.id.to_s}/edit"
fill_in "Title", with: "An edited question"
fill_in "Description", with: "Just a quick edit"
click_button "Ask Everyone"
end

Then /^I should be told the question was updated$/ do
page.should have_content("successfully updated")
end

Then /^I should see that the question was updated$/ do
page.should have_content('An edited question')
page.should have_content('Just a quick edit')
end
8 changes: 6 additions & 2 deletions features/step_definitions/user_steps.rb
@@ -1,5 +1,5 @@
Given /^a logged in user$/ do
@user = User.create!(username: "test_user",
def login_user
@user = User.create!(username: "test_user",
email: "test_user@example.com",
password: "foobar",
password_confirmation: "foobar")
Expand All @@ -9,6 +9,10 @@
click_button("Sign in")
end

Given /^a logged in user$/ do
login_user unless @user
end

When /^I go to look at my profile page$/ do
visit user_path(@user)
end
Expand Down

0 comments on commit 31f728c

Please sign in to comment.