require 'spec_helper'

feature 'BostonRB Presenters' do

  background do
    VCR.insert_cassette('boston_rb_calendar')
    setup_presenters
    visit root_path
  end

  scenario 'Viewing presentations by presenter' do
    click_link 'Presentations'
    within '#2011-05-10' do
      click_link @presenter_1.name
    end
    have_presentation_content(@presentation_1, :should)
    have_presentation_content(@presentation_2, :should_not)
    have_presentation_content(@presentation_3, :should)
  end

  after(:each) do
    VCR.eject_cassette
  end
end
feature 'LeaderBoard' do

  background do
    VCR.insert_cassette('boston_rb_calendar')
    setup_presenters
    visit root_path
  end

  scenario 'Viewing' do
    visit '/presenters/leaders'

    within '#2_presentations' do
      page.should have_content @presenter_1.name
    end

    within '#1_presentations' do
      page.should have_content @presenter_2.name
    end
  end

  after(:each) do
    VCR.eject_cassette
  end
end

def setup_presenters
  @presenter_1 = create(:presenter)
  @presenter_2 = create(:presenter)
  @presentation_1 = create(:presentation, :presented_at => 'May 10, 2011', :presenter => @presenter_1)
  @presentation_2 = create(:presentation, :presented_at => 'May 10, 2011', :presenter => @presenter_2)
  @presentation_3 = create(:presentation, :presented_at => 'April 12, 2011', :presenter => @presenter_1)
end

