61 lines
1.8 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', js: true do
expect(page).to have_selector "#table-#{@table.id} > h1", @table.title
end
scenario 'visitor can see the seats', js: true do
#TODO: Race condition exists without have_content
expect(page).to have_content "Sit"
@seat_count = page.find_all(".seat").length
expect(@seat_count).to eq @table.seats.count
end
scenario 'visitor can see the current game', js: true 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)
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', js: true do
visit tables_path
click_link @table.title
expect(page).to have_content "Sign out"
expect(page).to have_selector "#table-#{@table.id} > h1", @table.title
expect(current_path).to eq table_path(@table)
end
scenario 'user can see the current game', js: true do
#TODO: Fix race condition
visit table_path @table
#TODO: Write a better expectation
expect(page).to have_content "Inventory"
end
end
end