spec/lib/adapters/base_adapter_spec.rb in basquiat-1.1.1 vs spec/lib/adapters/base_adapter_spec.rb in basquiat-1.2.0

- old
+ new

@@ -1,11 +1,29 @@ require 'spec_helper' # Sample class used for testing -class SampleAdapter - include Basquiat::Adapters::Base -end - describe Basquiat::Adapters::Base do - subject { SampleAdapter.new } - it_behaves_like 'a Basquiat::Adapter' + subject(:adapter) { Basquiat::Adapters::Base.new } + + [:disconnect, :subscribe_to, :publish].each do |meth| + it "raise a SubclassResponsibility error if #{meth} isn't implemented" do + expect { adapter.public_send(meth) }.to raise_error Basquiat::Errors::SubclassResponsibility + end + end + + it 'raise error when using an unregistered strategy' do + # expect(adapter.use_strategy(:not_here)).to raise_error StrategyNotRegistered + end + + it 'register a requeue strategy' do + class CoolStuff + end + adapter.class.register_strategy :cool_stuff, CoolStuff + expect(adapter.strategies).to have_key :cool_stuff + end + + it 'merges the options with the default ones' do + opts = adapter.instance_variable_get(:@options) + adapter.adapter_options(nice_option: '127.0.0.2') + expect(opts[:nice_option]).to eq('127.0.0.2') + end end