Skip to content

Commit 0ad1fae

Browse files
committed
better naming and grouping for forum acceptance tests
1 parent 1da0cef commit 0ad1fae

1 file changed

Lines changed: 71 additions & 63 deletions

File tree

spec/acceptance/forum_spec.rb

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,97 @@
11
require File.dirname(__FILE__) + '/acceptance_helper'
22

33
feature "Forums" do
4-
5-
scenario "can view all of them" do
6-
@hacker = Factory(:hacker)
7-
log_in @hacker
84

9-
visit "/forums"
5+
describe "discussions" do
106

11-
page.should have_content "Learning Ruby"
12-
page.should have_content "Hackety Help"
13-
page.should have_content "Clubhouse"
14-
end
7+
scenario "can be viewed" do
8+
@hacker = Factory(:hacker)
9+
log_in @hacker
1510

16-
scenario "can view discussions" do
17-
@hacker = Factory(:hacker)
18-
log_in @hacker
11+
title = "I need help!"
12+
Factory(:discussion, :title => title, :forum => "learning_ruby")
1913

20-
title = "I need help!"
21-
Factory(:discussion, :title => title, :forum => "learning_ruby")
14+
visit "/forums"
15+
click_link "Learning Ruby"
16+
page.should have_content title
17+
end
2218

23-
visit "/forums"
24-
click_link "Learning Ruby"
25-
page.should have_content title
26-
end
19+
scenario "can be created when logged in" do
20+
@hacker = Factory(:hacker)
21+
log_in @hacker
2722

28-
scenario "view replies" do
29-
@hacker = Factory(:hacker)
30-
log_in @hacker
23+
visit "/forums/learning_ruby"
24+
click_link "New Discussion"
3125

32-
Factory(:discussion_with_reply, :title => "I need help", :forum => "learning_ruby")
26+
fill_in "Title", :with => "HALP!"
27+
fill_in "Body", :with => "I'm really unsure as to how to do something."
28+
click_button "Submit"
3329

34-
visit "/forums/learning_ruby/i_need_help"
35-
page.should have_content "I need help"
36-
page.should have_content "I'm here to help!"
37-
end
30+
should_be_on "/forums/learning_ruby/halp"
31+
page.should have_content "Discussion created!"
32+
page.should have_content "HALP!"
33+
page.should have_content "By #{@hacker.username}"
34+
end
3835

39-
scenario "make a new reply" do
40-
@hacker = Factory(:hacker)
41-
log_in @hacker
36+
scenario "can't be created when not logged in" do
4237

43-
Factory(:discussion_with_reply, :title => "I need help", :forum => "learning_ruby")
44-
visit "/forums/learning_ruby/i_need_help"
45-
click_link "Reply"
46-
fill_in "Body", :with => "I'll help you!"
47-
click_button "Create Reply"
48-
should_be_on "/forums/learning_ruby/i_need_help"
49-
page.should have_content "Replied!"
50-
page.should have_content "I'll help you"
51-
page.should have_content "#{@hacker.username} says:"
52-
end
38+
visit "/forums"
39+
click_link "Learning Ruby"
5340

54-
scenario "make a new discussion" do
55-
@hacker = Factory(:hacker)
56-
log_in @hacker
41+
page.should_not have_content "New Discussion"
42+
end
5743

58-
visit "/forums/learning_ruby"
59-
click_link "New Discussion"
44+
end
6045

61-
fill_in "Title", :with => "HALP!"
62-
fill_in "Body", :with => "I'm really unsure as to how to do something."
63-
click_button "Submit"
46+
describe "replies" do
47+
48+
scenario "can be viewed" do
49+
@hacker = Factory(:hacker)
50+
log_in @hacker
51+
52+
Factory(:discussion_with_reply, :title => "I need help", :forum => "learning_ruby")
53+
54+
visit "/forums/learning_ruby/i_need_help"
55+
page.should have_content "I need help"
56+
page.should have_content "I'm here to help!"
57+
end
58+
59+
scenario "can be created when logged in" do
60+
@hacker = Factory(:hacker)
61+
log_in @hacker
62+
63+
Factory(:discussion_with_reply, :title => "I need help", :forum => "learning_ruby")
64+
visit "/forums/learning_ruby/i_need_help"
65+
click_link "Reply"
66+
fill_in "Body", :with => "I'll help you!"
67+
click_button "Create Reply"
68+
should_be_on "/forums/learning_ruby/i_need_help"
69+
page.should have_content "Replied!"
70+
page.should have_content "I'll help you"
71+
page.should have_content "#{@hacker.username} says:"
72+
end
73+
74+
scenario "can't be created when not logged in" do
75+
Factory(:discussion, :title => "I need help!", :forum => "learning_ruby")
76+
77+
visit "/forums/learning_ruby/i_need_help"
78+
page.should_not have_content "Reply"
79+
end
6480

65-
should_be_on "/forums/learning_ruby/halp"
66-
page.should have_content "Discussion created!"
67-
page.should have_content "HALP!"
68-
page.should have_content "By #{@hacker.username}"
6981
end
70-
71-
scenario "Can't make discussions when logged out" do
82+
83+
scenario "can all be viewed" do
84+
@hacker = Factory(:hacker)
85+
log_in @hacker
7286

7387
visit "/forums"
74-
click_link "Learning Ruby"
75-
76-
page.should_not have_content "New Discussion"
77-
end
7888

79-
scenario "Can't make replies when logged out" do
80-
Factory(:discussion, :title => "I need help!", :forum => "learning_ruby")
81-
82-
visit "/forums/learning_ruby/i_need_help"
83-
page.should_not have_content "Reply"
89+
page.should have_content "Learning Ruby"
90+
page.should have_content "Hackety Help"
91+
page.should have_content "Clubhouse"
8492
end
8593

86-
scenario "breadcrumbs" do
94+
scenario "shows breadcrumbs" do
8795
discussion = Factory(:discussion, :forum => "learning_ruby")
8896
visit "/forums/learning_ruby/#{discussion.slug}"
8997

0 commit comments

Comments
 (0)