/
setup_spec.rb
48 lines (39 loc) · 1.18 KB
/
setup_spec.rb
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
46
47
48
require 'spec_helper'
describe Eventstorm,'.setup' do
after :each do
# Reset Eventstorm module in prishtine state
if Eventstorm.instance_variable_defined?(:@client)
Eventstorm.send(:remove_instance_variable,:@client)
end
end
let(:object) { described_class }
subject { object.setup(target) }
context 'when it was not called before accessing client' do
it 'should raise error' do
expect do
object.client.should
end.to raise_error(RuntimeError,'Evenstorm was not setup, call Evenstorm.setup(target)')
end
end
context 'when called' do
let(:target) { 'tcp://localhost:600' }
it 'should store instance in Evenstorm.client' do
subject
object.client.should be_a(Eventstorm::Client)
end
it 'should initialize client with target' do
subject
object.client.targets.should == [target]
end
it 'should return self' do
subject.should == described_class
end
end
context 'when called twice' do
let(:target) { 'tcp://localhost:600' }
it 'should raise error' do
subject
expect { subject }.to raise_error(RuntimeError,'Eventstorm.setup was already called')
end
end
end