-
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
a4c1a91
commit 74c39f1
Showing
1 changed file
with
66 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,66 @@ | ||
require 'spec_helper' | ||
|
||
describe KOSapiClient::Resource::DivisionsBuilder 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::DivisionsBuilder.new('http://example.com', http_client, url_builder) } | ||
|
||
describe '#courses' do | ||
|
||
before { allow(url_builder).to receive(:set_path) } | ||
|
||
it 'throws error when division id is not set' do | ||
expect { builder.courses }.to raise_error(RuntimeError) | ||
end | ||
|
||
it 'return self' do | ||
builder.find(69) | ||
expect(builder.courses).to eq builder | ||
end | ||
|
||
it 'adds courses to URL' do | ||
expect(url_builder).to receive(:set_path).with(69, 'courses') | ||
builder.find(69).courses | ||
end | ||
end | ||
|
||
describe '#subdivisions' do | ||
|
||
before { allow(url_builder).to receive(:set_path) } | ||
|
||
it 'throws error when division id is not set' do | ||
expect { builder.subdivisions }.to raise_error(RuntimeError) | ||
end | ||
|
||
it 'return self' do | ||
builder.find(69) | ||
expect(builder.subdivisions).to eq builder | ||
end | ||
|
||
it 'adds subdivisions to URL' do | ||
expect(url_builder).to receive(:set_path).with(69, 'subdivisions') | ||
builder.find(69).subdivisions | ||
end | ||
end | ||
|
||
describe '#teachers' do | ||
|
||
before { allow(url_builder).to receive(:set_path) } | ||
|
||
it 'throws error when division id is not set' do | ||
expect { builder.teachers }.to raise_error(RuntimeError) | ||
end | ||
|
||
it 'return self' do | ||
builder.find(69) | ||
expect(builder.teachers).to eq builder | ||
end | ||
|
||
it 'adds teachers to URL' do | ||
expect(url_builder).to receive(:set_path).with(69, 'teachers') | ||
builder.find(69).teachers | ||
end | ||
end | ||
end |