Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. feature 'User invites friend' do
  4. scenario 'User successfully invites friend and invitation is accepted' do
  5. alice = Fabricate(:user)
  6. sign_in(alice)
  7.  
  8. invite_a_friend
  9. friend_accepts_invitation
  10. friend_signs_in
  11.  
  12. friend_should_follow(alice)
  13. invited_should_follow_friend(alice)
  14.  
  15. clear_email
  16. end
  17.  
  18. def invite_a_friend
  19. visit new_invitation_path
  20. fill_in "Friend's Name", with: "John Doe"
  21. fill_in "Friend's Email Address", with: "john@example.com"
  22. fill_in "Message", with: "Join this site."
  23. click_button "Send Invitation"
  24. sign_out
  25. end
  26.  
  27. def friend_accepts_invitation
  28. open_email "john@example.com"
  29. current_email.click_link("Accept this invitation")
  30.  
  31. fill_in "Password", with: "password"
  32. fill_in "Confirm Password", with: "password"
  33. fill_in "Full Name", with: "John Doe"
  34. click_button "Sign Up"
  35. end
  36.  
  37. def friend_signs_in
  38. fill_in "Email Address", with: "john@example.com"
  39. fill_in "Password", with: "password"
  40. click_button "Sign in"
  41. end
  42.  
  43. def friend_should_follow(user)
  44. click_link "People"
  45. expect(page).to have_content user.full_name
  46. sign_out
  47. end
  48.  
  49. def invited_should_follow_friend(inviter)
  50. sign_in(inviter)
  51. click_link "People"
  52. expect(page).to have_content 'John Doe'
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement