Skip to content

Commit

Permalink
Add spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervbk committed Sep 21, 2017
1 parent afcd0a6 commit 12e156c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/dummy_autoscaler_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe 'Dummy Sensor and Actuator integration test' do
before(:context) do
@logger = Logger.new(STDOUT)
end

it 'should initialize correctly' do
sensor = SidekiqAutoscaler::Sensor::DummySensor.new
actuator = SidekiqAutoscaler::Actuator::DummyActuator.new
as = SidekiqAutoscaler::Autoscaler.new(sensor, actuator)
as.logger = @logger

as.start!(0)
sleep 5
as.stop!
end
end
38 changes: 38 additions & 0 deletions spec/heroku_worker_actuator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'
require 'sidekiq_autoscaler/actuator/heroku_worker_actuator'

describe 'HerokuWorkerActuator' do
before(:context) do
end


it 'should initialize with params' do
SidekiqAutoscaler::Actuator::HerokuWorkerActuator.new({
'SIDEKIQ_AUTOSCALER_APP_NAME' => 'not_empty',
'SIDEKIQ_AUTOSCALER_HEROKU_API_KEY' => 'not_empty'
})
end
end

describe 'HerokuWorkerActuator Exceptions' do
before(:context) do
end

it 'should fail on initialize without app_name' do
expect {
SidekiqAutoscaler::Actuator::HerokuWorkerActuator.new({
'SIDEKIQ_AUTOSCALER_HEROKU_API_KEY' => 'not_empty'
})
}.to raise_error(StandardError)
end

it 'should fail on initialize without heroku_api_key' do
expect {
SidekiqAutoscaler::Actuator::HerokuWorkerActuator.new({
'SIDEKIQ_AUTOSCALER_APP_NAME' => 'not_empty'
})
}.to raise_error(StandardError)
end

end

16 changes: 16 additions & 0 deletions spec/sidekiq_sensor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'
require 'sidekiq_autoscaler/sensor/sidekiq_sensor'

describe 'SidekiqSensor' do
before(:context) do
end


it 'should initialize with params' do
SidekiqAutoscaler::Sensor::SidekiqSensor.new({
'SIDEKIQ_AUTOSCALER_APP_NAME' => 'not_empty',
'SIDEKIQ_AUTOSCALER_HEROKU_API_KEY' => 'not_empty'
})
end
end

16 changes: 16 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ref http://stackoverflow.com/questions/4398262/setup-rspec-to-test-a-gem-not-rails
require 'bundler/setup'
Bundler.setup

require 'sidekiq_autoscaler'

require 'logger'

require 'rspec'
require 'rspec/collection_matchers'

RSpec.configure do |config|
# config.color_enabled = true
config.formatter = 'documentation'
#RAILS 5:config.file_fixture_path = "spec/example"
end

0 comments on commit 12e156c

Please sign in to comment.