From a67eee6ca4b070d8f94708b4879e3526e1b15b83 Mon Sep 17 00:00:00 2001 From: Anthony Davis Date: Wed, 16 Oct 2013 01:15:34 -0500 Subject: [PATCH] Prototype two-client headless Create/Find Session test --- web/spec/features/find_sessions_spec.rb | 54 +++++++++++++++++++++++-- web/spec/support/utilities.rb | 10 ++++- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/web/spec/features/find_sessions_spec.rb b/web/spec/features/find_sessions_spec.rb index 311dd6366..ff476c6cc 100644 --- a/web/spec/features/find_sessions_spec.rb +++ b/web/spec/features/find_sessions_spec.rb @@ -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 diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index abbec6d15..e91b1bb03 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -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 \ No newline at end of file +end