Prototype two-client headless Create/Find Session test

This commit is contained in:
Anthony Davis 2013-10-16 01:15:34 -05:00
parent 17c7e73894
commit a67eee6ca4
2 changed files with 59 additions and 5 deletions

View File

@ -14,12 +14,58 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
before(:each) do
UserMailer.deliveries.clear
sign_in_poltergeist user
visit "/#/findSession"
find('#find-session-form')
end
# when the find session page loads, it should show that there are no sessions
it { should have_selector('#sessions-none-found') }
it "shows there are no sessions" do
sign_in_poltergeist user
visit "/#/findSession"
find('#find-session-form')
page.should have_selector('#sessions-none-found')
end
it "finds another public session", :slow => true do
@unique_session_desc = 'Description found easily'
in_client(:one) do
sign_in_poltergeist user
visit "/#/createSession"
sleep 5 # this was in the cucumber steps file and it breaks when i remove it here
# pick a genre
page.select("Rock", :from => "genres")
# fill in description
page.fill_in 'description', :with => @unique_session_desc
# check box for legal terms
page.check('intellectual-property')
# create the session
page.find('#btn-create-session').click
# verify that the in-session page is showing
expect(page).to have_selector('h2', text: 'my tracks')
# with our description showing
# click into session description
# page.find("#session-info").should have_content @unique_session_desc
end
in_client(:two) do
sign_in_poltergeist user
visit "/#/findSession"
find('#find-session-form')
sleep 5 # not happy with this
expect(page).to have_text(@unique_session_desc)
end
end
end

View File

@ -4,6 +4,14 @@ def cookie_jar
Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
end
def in_client(name) # to assist multiple-client RSpec/Capybara testing
Capybara.session_name = name
yield
end
def sign_in(user)
visit signin_path
fill_in "Email", with: user.email
@ -25,4 +33,4 @@ def sign_in_poltergeist(user)
else
page.driver.browser.manage.add_cookie :name => :remember_token, :value => user.remember_token
end
end
end