Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. feature "invitations" do
  4. given!(:alice) { Fabricate(:user) }
  5.  
  6. scenario "user invites a friend", {js: true, vcr: true } do
  7. sign_in_user(alice)
  8. click_link("Welcome")
  9. click_link("Invite a Friend")
  10.  
  11. submit_invitation_form_and_sign_out("Betty", "foo@bar.com")
  12. open_email_and_click_link("foo@bar.com")
  13. expect_name_and_email_fields_to_be_filled("Betty", "foo@bar.com")
  14.  
  15. submit_register_form('password')
  16. binding.pry
  17. sign_in_betty
  18. expect_people_page_to_include(alice)
  19.  
  20. click_link "Welcome"
  21. click_link "Sign Out"
  22. sign_in_user(alice)
  23. expect_people_page_to_include(newly_created_user("Betty"))
  24.  
  25. clear_emails
  26. end
  27.  
  28. def submit_invitation_form_and_sign_out(name, email)
  29. fill_in "Friend's Name", with: name
  30. fill_in "Friend's Email", with: email
  31. click_button "Send Invitation"
  32. click_link("Welcome")
  33. click_link "Sign Out"
  34. end
  35.  
  36. def open_email_and_click_link(email)
  37. open_email(email)
  38. current_email.click_link("Join Now!")
  39. end
  40.  
  41. def expect_name_and_email_fields_to_be_filled(name, email)
  42. expect(page).to have_field "Email", with: email
  43. expect(page).to have_field "Full Name", with: name
  44. end
  45.  
  46. def submit_register_form(password)
  47. fill_in "Password", with: password
  48. fill_in "Confirm Password", with: password
  49. fill_in "Credit Card Number", with: '4242424242424242'
  50. fill_in "Security Code", with: '123'
  51. select "7 - July", from: 'exp-month'
  52. select "2018", from: 'exp-year'
  53. click_button "Sign Up"
  54. end
  55.  
  56. def newly_created_user(name)
  57. User.find_by(full_name: name)
  58. end
  59.  
  60. def sign_in_betty
  61. visit '/sign_in'
  62. fill_in "Email Address", with: "foo@bar.com"
  63. fill_in "Password", with: 'password'
  64. click_button 'Sign In'
  65. end
  66.  
  67. def expect_people_page_to_include(user)
  68. click_link "People"
  69. expect(page).to have_content(user.full_name)
  70. end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement