-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |