Sha256: e0d466dba983c1e52f83d574b9d48834ca4f30c849e999d09ace46658e32a846

Contents?: true

Size: 1.91 KB

Versions: 32

Compression:

Stored size: 1.91 KB

Contents

require File.join(File.dirname(__FILE__), '../../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')
      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

32 entries across 32 versions & 1 rubygems

Version Path
fb_graph-1.6.7 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.5 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.4 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.3 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.2 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.1 spec/fb_graph/connections/events_spec.rb
fb_graph-1.6.0 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.5 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.4 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.3 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.2 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.1 spec/fb_graph/connections/events_spec.rb
fb_graph-1.5.0 spec/fb_graph/connections/events_spec.rb
fb_graph-1.4.1 spec/fb_graph/connections/events_spec.rb
fb_graph-1.4.0 spec/fb_graph/connections/events_spec.rb
fb_graph-1.3.9 spec/fb_graph/connections/events_spec.rb
fb_graph-1.3.8 spec/fb_graph/connections/events_spec.rb
fb_graph-1.3.7 spec/fb_graph/connections/events_spec.rb
fb_graph-1.3.6 spec/fb_graph/connections/events_spec.rb
fb_graph-1.3.5 spec/fb_graph/connections/events_spec.rb