-
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
1 parent
78cdc14
commit a305239
Showing
2 changed files
with
59 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
describe KOSapiClient::Entity::Branch do | ||
let(:attributes) {{ | ||
capacity: '60', | ||
code: '3902R031', | ||
division: { xlink_href: 'divisions/13136/', __content__: 'katedra počítačů' }, | ||
diploma_name: [ | ||
{ xml_lang: 'cs', __content__: 'Softwarové inženýrství' }, | ||
{ xml_lang: 'en', __content__: 'Software Engineering' }, | ||
], | ||
guarantor: { xlink_href: 'people/jelinek/', __content__: 'doc. Ing. Ivan Jelínek CSc.' }, | ||
name: [ | ||
{ xml_lang: 'cs', __content__: 'Softwarové inženýrství' }, | ||
{ xml_lang: 'en', __content__: 'Software Engineering' }, | ||
], | ||
open_for_admission: 'true', | ||
}} | ||
|
||
it 'parses branch attributes' do | ||
branch = KOSapiClient::Entity::Branch.parse(attributes) | ||
expect(branch.capacity).to eq 60 | ||
expect(branch.code).to eq '3902R031' | ||
expect(branch.division).to be_an_instance_of KOSapiClient::Entity::Link | ||
expect(branch.division.link_href).to eq 'divisions/13136/' | ||
expect(branch.division.link_title).to eq 'katedra počítačů' | ||
expect(branch.guarantor).to be_an_instance_of KOSapiClient::Entity::Link | ||
expect(branch.guarantor.link_href).to eq 'people/jelinek/' | ||
expect(branch.guarantor.link_title).to eq 'doc. Ing. Ivan Jelínek CSc.' | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'spec_helper' | ||
|
||
describe KOSapiClient::Resource::BranchesBuilder do | ||
|
||
let(:url_builder) { instance_double(KOSapiClient::URLBuilder, url: 'http://example.com') } | ||
let(:response) { double(foo: :bar) } | ||
let(:http_client) { double(send_request: response) } | ||
subject(:builder) { KOSapiClient::Resource::BranchesBuilder.new('http://example.com', http_client, url_builder)} | ||
|
||
describe '#study_plans' do | ||
|
||
before { allow(url_builder).to receive(:set_path) } | ||
|
||
it 'throws error when branch id is not set' do | ||
expect { builder.study_plans }.to raise_error(RuntimeError) | ||
end | ||
|
||
it 'returns self' do | ||
builder.find(69) | ||
expect(builder.study_plans).to eq builder | ||
end | ||
|
||
it 'adds studyPlans to URL' do | ||
expect(url_builder).to receive(:set_path).with(69, 'studyPlans') | ||
builder.find(69).study_plans | ||
end | ||
end | ||
end |