Sha256: bddebcb6f759c2171c42380c9dea2ce337beb74f2e362dfa62599e7fcdc6f403

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Courier::Service::Facebook do
  describe '#deliver!' do
    before do
      @owner = mock_owner :facebook_id=>123
    end
    let(:owner) { @owner }
    let(:message) { mock_message :owner=>owner, :options=>{:text=>'text'} }

    it 'posts messages with Koala' do
      owner.stub(:facebook_token) { 'fbtoken' }

      message.should_receive(:mark_as_delivered!)

      graph = double
      graph.should_receive(:put_object).with(123,'feed',{:message=>'text'}) { true }
      Koala::Facebook::GraphAPI.should_receive(:new).with('fbtoken') { graph }

      subject.stub_chain('messages.fresh') { [message] }
      subject.deliver_all!
    end

    it 'do nothing if there is no token' do
      Koala::Facebook::GraphAPI.should_not_receive(:new)

      subject.stub_chain('messages.fresh') { [message] }
      subject.deliver_all!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
courier-0.2.4 spec/courier/service/facebook_spec.rb
courier-0.2.3 spec/courier/service/facebook_spec.rb