|
1 | 1 | require File.dirname(__FILE__) + '/acceptance_helper' |
2 | 2 |
|
3 | 3 | feature "Forums" do |
4 | | - |
5 | | - scenario "can view all of them" do |
6 | | - @hacker = Factory(:hacker) |
7 | | - log_in @hacker |
8 | 4 |
|
9 | | - visit "/forums" |
| 5 | + describe "discussions" do |
10 | 6 |
|
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 |
15 | 10 |
|
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") |
19 | 13 |
|
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 |
22 | 18 |
|
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 |
27 | 22 |
|
28 | | - scenario "view replies" do |
29 | | - @hacker = Factory(:hacker) |
30 | | - log_in @hacker |
| 23 | + visit "/forums/learning_ruby" |
| 24 | + click_link "New Discussion" |
31 | 25 |
|
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" |
33 | 29 |
|
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 |
38 | 35 |
|
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 |
42 | 37 |
|
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" |
53 | 40 |
|
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 |
57 | 43 |
|
58 | | - visit "/forums/learning_ruby" |
59 | | - click_link "New Discussion" |
| 44 | + end |
60 | 45 |
|
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 |
64 | 80 |
|
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}" |
69 | 81 | 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 |
72 | 86 |
|
73 | 87 | visit "/forums" |
74 | | - click_link "Learning Ruby" |
75 | | - |
76 | | - page.should_not have_content "New Discussion" |
77 | | - end |
78 | 88 |
|
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" |
84 | 92 | end |
85 | 93 |
|
86 | | - scenario "breadcrumbs" do |
| 94 | + scenario "shows breadcrumbs" do |
87 | 95 | discussion = Factory(:discussion, :forum => "learning_ruby") |
88 | 96 | visit "/forums/learning_ruby/#{discussion.slug}" |
89 | 97 |
|
|
0 commit comments