jam-cloud/features/step_definitions/create_session_steps.rb

80 lines
2.5 KiB
Ruby

Given /^I am logged in to the client$/ do
@user = FactoryGirl.create(:user)
login(@user, page) # page == the default context
end
When /^I create a public music session$/ do
# the relatively unique name of the session we will create
@session_description = 'A new session for anyone to find and play with me'
# Walk us through the FTUE screens...
page.find("a[href='#/ftue2']").click
sleep 1
page.find("a[href='#/ftue3']").click
sleep 1
page.find('div[data-step="step1"] button.startTestButton').click
sleep 1
page.find("#poorAudioButton").click
sleep 1
page.find("#goodAudioButton").click
sleep 1
page.find("[cucumber-id='ftue-home-link']").click
sleep 1
page.find("[layout-link='createSession']").click
sleep 1
# fill out minimially required elements of the form
page.choose 'music_access_true' # public session
# pick a genre, any genre
page.select 'African', :from => 'genres'
page.fill_in 'description', :with => @session_description
# create the session
click_button 'Create Session'
# verify that the 'in-session' page is showing, with our description showing
page.find("#session-info").should have_content @session_description
end
Then /^I should be in a music session that another musician can find$/ do
# now log in a second user
@second_session = Capybara::Session.new(Capybara.current_driver, Capybara.app)
@user2 = FactoryGirl.create(:user)
login(@user2, @second_session)
# Walk us through the FTUE screens...
@second_session.find("a[href='#/ftue2']").click
sleep 1
@second_session.find("a[href='#/ftue3']").click
sleep 1
@second_session.find('div[data-step="step1"] button.startTestButton').click
sleep 1
@second_session.find("#poorAudioButton").click
sleep 1
@second_session.find("#goodAudioButton").click
sleep 1
@second_session.find("[cucumber-id='ftue-home-link']").click
sleep 1
# click find sessions
@second_session.find("[layout-link='findSession']").click
# and see the session with the same description we created earlier show up
@second_session.find("tr[data-sortScore]").should have_content @session_description
end
When /^that other musician should be able to join my public session$/ do
# and finally join that session as the other user
@second_session.find("tr[data-sortScore] a", :text =>"Join").click
# verify that the 'in-session' page is showing, with our description showing
@second_session.find("#session-info").should have_content @session_description
end