spec/unit/server_spec.rb in goliath-1.0.3 vs spec/unit/server_spec.rb in goliath-1.0.4
- old
+ new
@@ -22,23 +22,23 @@
@s.address.should == '10.2.1.1'
@s.port.should == 2020
end
it 'accepts a logger' do
- logger = mock('logger')
+ logger = double('logger')
@s.logger = logger
@s.logger.should == logger
end
it 'accepts an app' do
- app = mock('app')
+ app = double('app')
@s.app = app
@s.app.should == app
end
it 'accepts config' do
- config = mock('config')
+ config = double('config')
@s.config = config
@s.config.should == config
end
end
@@ -57,70 +57,58 @@
@s.port = port
@s.start
end
it 'provides the app to each connection' do
- app = mock('application')
+ app = double('application')
- conn = mock("connection").as_null_object
+ conn = double("connection").as_null_object
conn.should_receive(:app=).with(app)
EM.should_receive(:start_server).and_yield(conn)
@s.app = app
@s.start
end
it 'provides the logger to each connection' do
- logger = mock('logger')
+ logger = double('logger')
- conn = mock("connection").as_null_object
+ conn = double("connection").as_null_object
conn.should_receive(:logger=).with(logger)
EM.should_receive(:start_server).and_yield(conn)
@s.logger = logger
@s.start
end
it 'provides the status object to each connection' do
- status = mock('status')
+ status = double('status')
- conn = mock("connection").as_null_object
+ conn = double("connection").as_null_object
conn.should_receive(:status=).with(status)
EM.should_receive(:start_server).and_yield(conn)
@s.status = status
@s.start
end
it 'loads the config for each connection' do
- conn = mock("connection").as_null_object
+ conn = double("connection").as_null_object
EM.should_receive(:start_server).and_yield(conn)
@s.should_receive(:load_config)
@s.start
end
end
- describe 'stop' do
- it 'logs when receives TERM signal' do
- EM.run do
- logger = mock('logger')
- logger.should_receive(:info).with('Stopping server...')
- @s.logger = logger
- @s.start
- @s.stop
- end
- end
- end
-
context 'config parsing' do
context 'environment' do
after(:all) do
# Be sure to revert to correct env
- Goliath.env = :test
+ Goliath.env = :test
end
it 'executes the block if the environment matches the provided string' do
Goliath.env = :development
block_run = false
@s.environment('development') { block_run = true }