require File.expand_path('../spec_helper', __FILE__) require 'yammer/response' describe Yammer::Response do context 'successful response' do subject { Yammer::Response.new(double( :header => { 'Location' => 'https://www.yammer.com/api/v1/messages/2' }, :body => '{ "system_message":false, "direct_message":true, "id":10928508, "privacy":"private", "network_id":1 }', :code => '200') )} describe '#raw_body' do it 'returns a string' do expect(subject.raw_body).to eq('{ "system_message":false, "direct_message":true, "id":10928508, "privacy":"private", "network_id":1 }') end end describe '#body' do it 'return a hash' do expect(subject.body).to eq({ :system_message => false, :direct_message => true, :id => 10928508, :privacy => 'private', :network_id => 1 }) end end describe '#success' do it 'returns true' do expect(subject.success?).to eq true end end describe '#created?' do it 'returns true' do expect(subject.created?).to eq false end end end context 'failed response' do subject { Yammer::Response.new(double( :header => {}, :body => '', :code => '500')) } describe '#raw_body' do it 'returns a string' do expect(subject.raw_body).to eq('') end end describe '#body' do it 'return a hash' do expect(subject.raw_body).to eq('') end end describe '#success' do it 'returns true' do expect(subject.success?).to eq false end end describe '#created?' do it 'returns true' do expect(subject.created?).to eq false end end end end