Sha256: 334ed31cbe071fa9a93c44abe37a545e7b0fa02f23cf89adf97b48a7a8503a37

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe Yammer::Message do

  before :all do
    Yammer.configure do |conf|
      conf.access_token = 'TolNOFka9Uls2DxahNi78A'
    end
  end

  after :all do
    Yammer.reset!
  end

  context 'class methods' do

    subject { Yammer::Message }

    describe '#create' do
      it 'creates a new group' do
        stub_request(:post, "https://www.yammer.com/api/v1/messages").with(
          :body    => { :name => 'rails team', :privacy => 'public' },
          :headers => {
            'Accept'          => 'application/json',
            'Authorization'   => "Bearer #{Yammer.access_token}",
            'Content-Type'    => 'application/x-www-form-urlencoded',
            'User-Agent'      => "Yammer Ruby Gem #{Yammer::Version}"
          }
        ).to_return(
          :status => 201,
          :body => '',
          :headers => {'Location' => 'https://www.yammer.com/api/v1/messages/2'}
        )
        subject.create(:name => 'rails team', :privacy => 'public')
      end
    end

    describe '#get' do
      it 'returns message response' do
        stub_request(:get, "https://www.yammer.com/api/v1/messages/1").with(
          :headers => {
            'Accept'          => 'application/json',
            'Authorization'   => "Bearer #{Yammer.access_token}",
            'User-Agent'      => "Yammer Ruby Gem #{Yammer::Version}"
          }
        ).to_return(
          :status => 200,
          :body => fixture('message.json'),
          :headers => {}
        )
        subject.get(1)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yammer-client-0.1.4 spec/model/message_spec.rb
yammer-client-0.1.3 spec/model/message_spec.rb