Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. require "feature_spec_helper"
  2.  
  3. RSpec.feature "Participant completes an Interview" do
  4. PROJECT_ID = 94 # Interview Project
  5. INTERVIEW_ID = 341 # Interview Task
  6. INTERVIEW_TASK_LIST_ID = 109 # Blanks
  7.  
  8. scenario "viewing the Interview" do
  9. sign_in_and_visit_interview
  10.  
  11. expect(page).to have_stimuli
  12. expect(page).to have_continue_button
  13. end
  14.  
  15. scenario "with valid data" do
  16. sign_in_and_visit_interview
  17.  
  18. complete_first_question
  19. complete_second_question
  20.  
  21. participant_is_redirected_to_task_list
  22. end
  23.  
  24. scenario "returning to an incomplete Interview" do
  25. sign_in_and_visit_interview
  26. complete_first_question
  27. visit(root_path)
  28.  
  29. visit_interview
  30.  
  31. expect(page).to have_stimuli_for_the_second_question
  32.  
  33. complete_second_question
  34. end
  35.  
  36. def have_stimuli_for_the_second_question
  37. have_content("This is the second Question!")
  38. end
  39.  
  40. def have_continue_button
  41. have_button(I18n.t("opinion.next"))
  42. end
  43.  
  44. def have_stimuli
  45. have_content("Hi, welcome to CrowdLab!")
  46. end
  47.  
  48. def complete_first_question
  49. click_button(I18n.t("opinion.next"))
  50. end
  51.  
  52. def complete_second_question
  53. click_button(I18n.t("opinion.finish"))
  54. end
  55.  
  56. def participant_is_redirected_to_task_list
  57. url = project_tasks_url(PROJECT_ID, task_list_id: INTERVIEW_TASK_LIST_ID)
  58. expect(current_url).to eq(url)
  59. end
  60.  
  61. def sign_in_and_visit_interview
  62. request_as_tenant("crowdlab")
  63. sign_in_as_participant
  64. visit_interview
  65. end
  66.  
  67. def visit_interview
  68. visit(interview_path)
  69. end
  70.  
  71. def interview_path
  72. project_interview_path(PROJECT_ID, INTERVIEW_ID)
  73. end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement