58 lines
1.6 KiB
Ruby
58 lines
1.6 KiB
Ruby
# Feature: Table show
|
|
# As a visitor
|
|
# I want to view a table
|
|
# So I can sit and play a game
|
|
feature 'Table show', :devise do
|
|
context "As a visitor" do
|
|
before(:each) do
|
|
@table = FactoryGirl.create :table
|
|
visit tables_path
|
|
click_link @table.title
|
|
end
|
|
# Scenario: Visitor can view a table
|
|
# Given I am not signed in
|
|
# When I visit a table
|
|
# Then I see the table attributes
|
|
scenario 'visitor can see the table' do
|
|
expect(page).to have_text @table.title
|
|
end
|
|
|
|
scenario 'visitor can see the seats' do
|
|
#TODO: Race condition exists without have_content
|
|
expect(page).to have_button "Sit"
|
|
@seat_count = page.find_all(".seat").length
|
|
expect(@seat_count).to eq @table.seats.count
|
|
end
|
|
|
|
scenario 'visitor can see the current game' do
|
|
#TODO: Write a better expectation
|
|
expect(page).to have_content "Hand to beat"
|
|
end
|
|
end
|
|
|
|
context "As a user" do
|
|
before(:each) do
|
|
@table = FactoryGirl.create :table
|
|
@user = FactoryGirl.create :user
|
|
signin(@user.email, @user.password)
|
|
visit tables_path
|
|
click_link @table.title
|
|
end
|
|
|
|
# Scenario: User can view a table
|
|
# Given I am signed in
|
|
# When I click a table
|
|
# Then I see the table attributes
|
|
scenario 'user can see the table' do
|
|
expect(page).to have_content "Sign out"
|
|
expect(page).to have_content @table.title
|
|
expect(current_path).to eq table_path(@table)
|
|
end
|
|
|
|
scenario 'user can see the current game' do
|
|
expect(page).to have_button "Sit"
|
|
end
|
|
|
|
end
|
|
end
|