Hi I am trying to write tests for the feature wherein a admin signs up, creates an event and then someone from audience can join the event and then asks questions that are then sent to the admin for approval. Currently this is my integration spec file
require ‘spec_helper’
feature "Admin can signup" do
scenario 'with valid email address and password' do
sign_up_admin
page.should have_content("Welcome! You have signed up successfully. Logged in as admin@admin.com.")
page.should have_link "Logout"
page.should have_link "Edit profile"
page.should have_link "Create an event"
end
scenario "and create an event." do
sign_up_admin
create_event
page.should have_css ".questions"
end
scenario "sees the questions that have been asked by the audience" do
sign_up_admin
create_event
end
end
def sign_up_admin
visit root_path
click_link "Sign up to create an event"
fill_in "Email",with: "admin@admin.com"
fill_in "Password",with: "a"*8
fill_in "Password confirmation",with: "a"*8
click_button "Sign up"
end
def create_event
click_link "Create an event"
page.should have_button "Create Event"
fill_in "Name",with:"Oracle"
click_button "Create Event"
end
I am stuck on this scenario
scenario "sees the questions that have been asked by the audience" do
sign_up_admin
create_event
# ask a guest to join the event. and then post a question to be approved by the admin.
end
So should I logout the admin, signin as a normal user, join the group, ask a question and then signin the admin again to check if the question asked exists?
Also what is the best way to let someone on a different browser notify that there is a new question? Should I use javascript polling or websockets?