# 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 sit at the table', js: true do click_button 'Sit' expect(page).to have_content "Guest" end end context "As a user" do # Scenario: User can view a table # Given I am signed in # When I click a table # Then I see an index of tables scenario 'visitor can see the table', js: true do @table = FactoryGirl.create :table # TODO: sign in visit tables_path click_link @table.title expect(page).to have_button "Sit" expect(page).to have_selector "#table-#{@table.id} > .title", @table.title expect(current_path).to eq table_path(@table) end end end