Sha256: aa541f4ae95f28156173edf8ba867134faf9ab6ba94f65bdd3dd76cceaf1371d
Contents?: true
Size: 1.69 KB
Versions: 6
Compression:
Stored size: 1.69 KB
Contents
require File.expand_path('../spec_helper', __FILE__) require 'yammer/response' describe Yammer::ApiResponse do context 'successful response' do subject do headers = { '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' Yammer::ApiResponse.new(headers, body, code) end 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::ApiResponse.new(double( :headers => {}, :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.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
Version data entries
6 entries across 6 versions & 1 rubygems