Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions spec/data_store_factory_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SimpleMapReduce::DataStoreFactory do
describe '.create' do
context "with 'default'" do
it 'returns DefaultDataStore instance' do
store = described_class.create('default')
expect(store).to be_a(SimpleMapReduce::DataStores::DefaultDataStore)
end
end

context "with 'remote'" do
let(:options) do
{
resource_name: 'jobs',
resource_id: '1',
server_url: 'http://example.com'
}
end

it 'returns RemoteDataStore instance' do
store = described_class.create('remote', options)
expect(store).to be_a(SimpleMapReduce::DataStores::RemoteDataStore)
end

it 'passes options to RemoteDataStore' do
expect(SimpleMapReduce::DataStores::RemoteDataStore).to receive(:new).with(options)
described_class.create('remote', options)
end
end

context 'with unsupported type' do
it 'raises ArgumentError' do
expect { described_class.create('foo') }.to raise_error(ArgumentError)
end
end
end
end