spec/lib/interfaces/base_spec.rb in basquiat-1.2.0 vs spec/lib/interfaces/base_spec.rb in basquiat-1.3.0.pre.1
- old
+ new
@@ -1,21 +1,22 @@
require 'spec_helper'
-# Sample class used for testing
-class SampleClass
- extend Basquiat::Base
- self.event_adapter = Basquiat::Adapters::Test
-end
-
describe Basquiat::Base do
+ # Sample class used for testing
+ class SampleClass
+ extend Basquiat::Base
+ self.adapter = Basquiat::Adapters::Test
+ end
+
subject { SampleClass }
- it '.event_adapter' do
+ it '.event_adapter= / .adapter=' do
expect(subject).to respond_to(:event_adapter=)
+ expect(subject).to respond_to(:adapter=)
end
- it '.event_source(option_hash)' do
+ it '.adapter_options(option_hash)' do
expect(subject).to respond_to(:adapter_options)
end
it 'set the adapter options' do
subject.adapter_options host: 'localhost', port: 5672, durable: true
@@ -43,12 +44,12 @@
expect(defaults.adapter).to be_a(Basquiat::Adapters::Test)
end
it 'publishes to the configured queue and exchanges' do
expect do
- subject.publish('test.message', message: 'useful test message')
- end.to change { subject.adapter.events('test.message').size }.by(1)
+ defaults.publish('test.message', message: 'useful test message')
+ end.to change { defaults.adapter.events('test.message').size }.by(1)
end
end
context 'as a Producer' do
it '#publish' do
@@ -85,16 +86,7 @@
end
subject.subscribe_to('some.event', :test_method)
expect(subject.listen(block: false)).to eq(%w(e e e))
end
- end
-
- it 'trigger an event after processing a message' do
- subject.publish('some.event', 'some message')
- subject.instance_eval <<-METHCALL
- subscribe_to 'some.event', ->(msg) { publish('other.event', "Redirected \#{msg}") }
- METHCALL
- expect { subject.listen(block: false) }.to_not raise_error
- expect(subject.adapter.events('other.event').size).to eq(1)
end
end