|
| 1 | +require File.dirname(__FILE__) + '/acceptance_helper' |
| 2 | + |
| 3 | +feature "Hackers" do |
| 4 | + |
| 5 | + scenario "can register" do |
| 6 | + |
| 7 | + visit '/signup' |
| 8 | + |
| 9 | + fill_in "Email", :with => "steve@example.com" |
| 10 | + fill_in "Username", :with => "steve" |
| 11 | + fill_in "Password", :with => "foobar" |
| 12 | + fill_in "Confirm Password", :with => "foobar" |
| 13 | + click_button "Create account" |
| 14 | + |
| 15 | + page.should have_content "Account created." |
| 16 | + should_be_on "/" |
| 17 | + end |
| 18 | + |
| 19 | + scenario "have visible profiles" do |
| 20 | + hacker = Factory(:hacker, :username => "steve") |
| 21 | + visit "/hackers/steve" |
| 22 | + page.should have_content "steve's page" |
| 23 | + end |
| 24 | + |
| 25 | + scenario "can't send messages to themselves" do |
| 26 | + @hacker = Factory(:hacker) |
| 27 | + log_in @hacker |
| 28 | + |
| 29 | + visit "/" |
| 30 | + click_link "My Page" |
| 31 | + should_be_on "/hackers/#{@hacker.username}" |
| 32 | + page.should_not have_content "Send steve a message" |
| 33 | + end |
| 34 | + |
| 35 | + scenario "can follow other hackers" do |
| 36 | + @fela = Factory(:hacker, :username => "fela") |
| 37 | + |
| 38 | + @steve = Factory(:hacker, :username => "steve") |
| 39 | + log_in @steve |
| 40 | + |
| 41 | + visit "/hackers/fela" |
| 42 | + click_link "Follow fela" |
| 43 | + |
| 44 | + page.should have_content "Now following fela." |
| 45 | + should_be_on "/hackers/steve" |
| 46 | + page.should have_content "Following: 1" |
| 47 | + |
| 48 | + visit "/hackers/fela" |
| 49 | + page.should have_content "Followers: 1" |
| 50 | + end |
| 51 | + |
| 52 | + scenario "can see followers" do |
| 53 | + @fela = Factory(:hacker, :username => "fela") |
| 54 | + @steve = Factory(:hacker, :username => "steve") |
| 55 | + |
| 56 | + @steve.follow! @fela |
| 57 | + |
| 58 | + visit "/hackers/fela" |
| 59 | + |
| 60 | + click_link "1" |
| 61 | + page.should have_content "steve" |
| 62 | + end |
| 63 | + |
| 64 | + scenario "can see others following" do |
| 65 | + @fela = Factory(:hacker, :username => "fela") |
| 66 | + @steve = Factory(:hacker, :username => "steve") |
| 67 | + @steve.follow! @fela |
| 68 | + |
| 69 | + visit "/hackers/steve" |
| 70 | + click_link "1" |
| 71 | + page.should have_content "fela" |
| 72 | + end |
| 73 | + |
| 74 | + scenario "can unfollow other hackers" do |
| 75 | + @steve = Factory(:hacker, :username => "steve") |
| 76 | + log_in @steve |
| 77 | + |
| 78 | + @fela = Factory(:hacker, :username => "fela") |
| 79 | + @steve.follow! @fela |
| 80 | + |
| 81 | + visit "/hackers/fela" |
| 82 | + click_link "Unfollow fela" |
| 83 | + should_be_on "/hackers/steve" |
| 84 | + |
| 85 | + page.should have_content "No longer following fela." |
| 86 | + page.should have_content "Following: 0" |
| 87 | + end |
| 88 | + |
| 89 | +end |
0 commit comments