Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Added missing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Rzegocki committed Apr 14, 2016
1 parent 79d2d64 commit ff85e4f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/fixtures/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,24 @@ def node(override = {})
wrong_param: 'bad'
},
appserver: {
adapter: 'unicorn',
delay: 3
},
framework: {
adapter: 'rails',
migrate: false
}
}
},
defaults: {
appserver: {
adapter: 'unicorn',
worker_processes: 8
},
framework: {
adapter: 'rails',
migration_command: 'rake db:migrate'
}
}
}.merge(override)

Expand Down
18 changes: 18 additions & 0 deletions spec/unit/libraries/drivers_appserver_factory_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'spec_helper'

describe Drivers::Appserver::Factory do
it 'raises error when unknown adapter is present' do
expect do
described_class.build(
aws_opsworks_app,
'deploy' => { aws_opsworks_app['shortname'] => { 'appserver' => { 'adapter' => 'tornado' } } }
)
end.to raise_error StandardError, 'There is no supported Appserver driver for given configuration.'
end

it 'returns a Unicorn class' do
appserver = described_class.build(aws_opsworks_app, node)
expect(appserver).to be_instance_of(Drivers::Appserver::Unicorn)
end
end
19 changes: 19 additions & 0 deletions spec/unit/libraries/drivers_appserver_unicorn_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'spec_helper'

describe Drivers::Appserver::Unicorn do
it 'receives and exposes app and node' do
driver = described_class.new(aws_opsworks_app, node)

expect(driver.app).to eq aws_opsworks_app
expect(driver.node).to eq node
expect(driver.options).to eq({})
end

it 'returns proper out data' do
expect(described_class.new(aws_opsworks_app, node).out).to eq(
worker_processes: 8,
delay: 3
)
end
end
18 changes: 18 additions & 0 deletions spec/unit/libraries/drivers_framework_factory_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'spec_helper'

describe Drivers::Framework::Factory do
it 'raises error when unknown adapter is present' do
expect do
described_class.build(
aws_opsworks_app,
'deploy' => { aws_opsworks_app['shortname'] => { 'framework' => { 'adapter' => 'django' } } }
)
end.to raise_error StandardError, 'There is no supported Framework driver for given configuration.'
end

it 'returns a Rails class' do
framework = described_class.build(aws_opsworks_app, node)
expect(framework).to be_instance_of(Drivers::Framework::Rails)
end
end
20 changes: 20 additions & 0 deletions spec/unit/libraries/drivers_framework_rails_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'spec_helper'

describe Drivers::Framework::Rails do
it 'receives and exposes app and node' do
driver = described_class.new(aws_opsworks_app, node)

expect(driver.app).to eq aws_opsworks_app
expect(driver.node).to eq node
expect(driver.options).to eq({})
end

it 'returns proper out data' do
expect(described_class.new(aws_opsworks_app, node).out).to eq(
deploy_environment: { 'RAILS_ENV' => 'production' },
migration_command: 'rake db:migrate',
migrate: false
)
end
end

0 comments on commit ff85e4f

Please sign in to comment.