shared_examples_for 'google_calendar' do

  let(:model) { Event }
  subject(:model) { Event }

  its(:client) { should be_kind_of(Google::APIClient) }

  it "#self.service" do
    VCR.use_cassette "google_service" do
      model.service.should be_kind_of(Google::APIClient::API)
    end
  end

  it "#self.calendars" do
    VCR.use_cassette "google_calendars" do
      calendars = model.google_calendars
      calendars.should be_kind_of(Array)
      calendars.first.should be_kind_of(Google::APIClient::Schema::Calendar::V3::CalendarListEntry) if calendars.any?
    end
  end

  it "#self.calendar" do
    VCR.use_cassette "google_calendar" do
      model.google_calendar("Test").should be_kind_of(Google::APIClient::Schema::Calendar::V3::CalendarListEntry)
    end
  end

  context "manage" do

    subject(:google_calendar) {
      VCR.use_cassette "google_calendar_create" do
        model.create_google_calendar("Test123")
      end
    }

    it { should be_kind_of(Google::APIClient::Schema::Calendar::V3::CalendarListEntry) }

    it "#self.events" do
      VCR.use_cassette "google_calendar_events" do
        events = model.google_events(google_calendar.id)
        events.should be_kind_of(Array)
        events.first.should be_kind_of(Google::APIClient::Schema::Calendar::V3::CalendarListEntry) if events.any?
      end
    end
  end

end