1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
require 'spec_helper'
describe JIRA::BaseFactory do
class JIRA::Resource::FooFactory < JIRA::BaseFactory; end
class JIRA::Resource::Foo; end
let(:client) { double }
subject { JIRA::Resource::FooFactory.new(client) }
it 'initializes correctly' do
expect(subject.class).to eq(JIRA::Resource::FooFactory)
expect(subject.client).to eq(client)
expect(subject.target_class).to eq(JIRA::Resource::Foo)
end
it 'proxies all to the target class' do
expect(JIRA::Resource::Foo).to receive(:all).with(client)
subject.all
end
it 'proxies find to the target class' do
expect(JIRA::Resource::Foo).to receive(:find).with(client, 'FOO')
subject.find('FOO')
end
it 'returns the target class' do
expect(subject.target_class).to eq(JIRA::Resource::Foo)
end
it 'proxies build to the target class' do
attrs = double
expect(JIRA::Resource::Foo).to receive(:build).with(client, attrs)
subject.build(attrs)
end
it 'proxies collection path to the target class' do
expect(JIRA::Resource::Foo).to receive(:collection_path).with(client)
subject.collection_path
end
it 'proxies singular path to the target class' do
expect(JIRA::Resource::Foo).to receive(:singular_path).with(client, 'FOO')
subject.singular_path('FOO')
end
end
|