Skip to content

Commit

Permalink
Added test for divisions resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
simacektomas committed Jan 21, 2018
1 parent a4c1a91 commit 74c39f1
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions spec/kosapi_client/resource/divisions_builder_spec.rb
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

0 comments on commit 74c39f1

Please sign in to comment.