Sha256: b517b3a206a5d9293767b0fdbbd7c812bc8ecfffea6b0065cfe8e49d607a662d

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe FbGraph::Connections::Events, '#events' do
  context 'when included by FbGraph::User' do
    before do
      fake_json(:get, 'matake/events', 'users/events/matake_public', :status => [401, 'Unauthorized'])
      fake_json(:get, 'matake/events?access_token=access_token', 'users/events/matake_private')
    end

    context 'when no access_token given' do
      it 'should raise FbGraph::Unauthorized' do
        lambda do
          FbGraph::User.new('matake').events
        end.should raise_exception(FbGraph::Unauthorized)
      end
    end

    context 'when access_token is given' do
      it 'should return events as FbGraph::Event' do
        events = FbGraph::User.new('matake', :access_token => 'access_token').events
        events.first.should == FbGraph::Event.new(
          '116600818359630',
          :access_token => 'access_token',
          :name => 'The Loyal We @ Rainy Day Bookstore and Cafe',
          :start_time => '2010-04-29T01:30:00+0000',
          :end_time => '2010-04-29T04:30:00+0000',
          :location => 'Nishi Azabu'
        )
        events.each do |event|
          event.should be_instance_of(FbGraph::Event)
        end
      end
    end
  end
end

describe FbGraph::Connections::Events, '#events!' do
  context 'when included by FbGraph::User' do
    before do
      fake_json(:post, 'matake/events', 'users/events/post_with_valid_access_token')
    end

    it 'should return generated note' do
      event = FbGraph::User.new('matake', :access_token => 'valid').event!(
        :name => 'FbGraph test event',
        :start_time => Time.utc(2010, 5, 11, 10, 0, 0).to_i,
        :end_time   => Time.utc(2010, 5, 11, 12, 0, 0).to_i
      )
      event.name.should == 'FbGraph test event'
      event.access_token.should == 'valid'
      event.start_time.should == Time.utc(2010, 5, 11, 10, 0, 0)
      event.end_time.should == Time.utc(2010, 5, 11, 12, 0, 0)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_graph-1.7.1 spec/fb_graph/connections/events_spec.rb