Skip to content

Commit

Permalink
Extended KOSapiResponse specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
tszolar committed Jul 24, 2014
1 parent 98ca95f commit ee661e5
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions spec/kosapi_client/kosapi_response_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
require 'spec_helper'

describe KOSapiClient::KOSapiResponse do
let(:parsed_result) { {id: 'urn:cvut:kos:courseevent:220200484405'} }
let(:result) { double(parsed: parsed_result) }
let(:preprocessed_hash) { {} }
let(:preprocessor) { instance_double(KOSapiClient::ResponsePreprocessor, preprocess: preprocessed_hash) }
let(:converter) { instance_double(KOSapiClient::ResponseConverter) }

subject(:response) { KOSapiClient::KOSapiResponse.new(result) }

context 'with paginated response' do
let(:result) { {atom_feed: {atom_entry: [:entry1, :entry2]}} }

describe '#is_paginated?' do

it 'returns true when result contains atom feed' do
expect(response.is_paginated?).to be
end

end

describe '#items' do

it 'returns all entries' do
expect(response.items).to eq [:entry1, :entry2]
end

end

describe '#item' do

it 'returns first entry' do
expect(response.item).to eq :entry1
end

end

end

context 'with not-paginated response' do
let(:result) { { atom_entry: :entry} }

describe '#is_paginated?' do

it 'returns false when result contains atom feed' do
expect(response.is_paginated?).not_to be
end

end

describe '#items' do

it 'returns single entry wrapped in array' do
expect(response.items).to eq [:entry]
end

end

describe '#item' do

it 'returns first entry' do
expect(response.item).to eq :entry
end

end
end

end

0 comments on commit ee661e5

Please sign in to comment.