Skip to content

Commit

Permalink
update minitests
Browse files Browse the repository at this point in the history
  • Loading branch information
katjacresanti committed Sep 4, 2024
1 parent 70e1896 commit 7975462
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 29 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec

group :development do
gem 'pry'
gem 'aws-sdk-codedeploy'
gem 'guard'
gem 'guard-minitest'
gem 'aws-sdk-codedeploy'
gem 'rspec'
gem 'pry'
end
2 changes: 1 addition & 1 deletion lib/egads/command/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Release < Group

desc '[remote] Symlinks SHA to current and restarts services. If needed, stages SHA'
class_option :force, type: :boolean, default: false, banner: 'Overwrite existing release'
class_option :deployment_id, type: :boolean, default: false, banner: 'Use the CodeDeploy deployment ID in the release directory'
class_option :deployment_id, type: :boolean, default: false, banner: 'Include deployment ID in release directory'
argument :sha, type: :string, required: true, desc: 'git SHA to stage'

def setup_environment
Expand Down
2 changes: 1 addition & 1 deletion lib/egads/command/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Stage < Group

desc '[remote] Readies SHA for release. If needed, generates URL for SHA and extracts'
class_option :force, type: :boolean, default: false, banner: 'Overwrite existing files'
class_option :deployment_id, type: :string, default: false, banner: 'Include deployment ID in release directory'
class_option :deployment_id, type: :boolean, default: false, banner: 'Include deployment ID in release directory'
argument :sha, type: :string, required: true, desc: 'git SHA to stage'

def setup_environment
Expand Down
21 changes: 9 additions & 12 deletions spec/egads_release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

require_relative 'spec_helper'

describe Egads::Release do
describe 'Egads::Release' do
subject { Egads::Release }

let(:sha) { 'abcdef123456' }
let(:options) { { force: false, deployment_id: true } }
let(:release_instance) { subject.new([sha], options) }

it 'should run the correct tasks' do
expect(subject.commands.keys).to eq %w(setup_environment stage run_before_release_hooks symlink_release restart run_after_release_hooks trim)
_(subject.commands.keys).must_equal %w[setup_environment stage run_before_release_hooks symlink_release restart run_after_release_hooks trim]
end

it 'should recognize the deployment_id class option' do
expect(release_instance.options[:deployment_id]).to eq true
end
it 'should have the correct class options' do
expected_options = {
force: { type: :boolean, default: false, banner: 'Overwrite existing release' },
deployment_id: { type: :boolean, default: false, banner: 'Include deployment ID in release directory' }
}

it 'should correctly pass the deployment_id option to the stage method' do
allow_any_instance_of(Egads::Stage).to receive(:stage).and_call_original
expect(release_instance.options[:deployment_id]).to eq(true)
actual_options = subject.class_options.transform_values { |opt| { type: opt.type, default: opt.default, banner: opt.banner }}
_(actual_options).must_equal expected_options
end
end
21 changes: 9 additions & 12 deletions spec/egads_stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

require_relative 'spec_helper'

describe Egads::Stage do
describe 'Egads::Stage' do
subject { Egads::Stage }

let(:sha) { 'abcdef123456' }
let(:options) { { force: false, deployment_id: true } }
let(:stage_instance) { subject.new([sha], options) }

it 'should run the correct tasks' do
expect(subject.commands.keys).to eq %w[setup_environment extract run_before_hooks bundle symlink_system_paths symlink_config_files run_after_stage_hooks mark_as_staged]
_(subject.commands.keys).must_equal %w[setup_environment extract run_before_hooks bundle symlink_system_paths symlink_config_files run_after_stage_hooks mark_as_staged]
end

it 'should recognize the deployment_id class option' do
expect(stage_instance.options[:deployment_id]).to eq true
end
it 'should have the correct class options' do
expected_options = {
force: { type: :boolean, default: false, banner: 'Overwrite existing files' },
deployment_id: { type: :boolean, default: false, banner: 'Include deployment ID in release directory'}
}

it 'should correctly pass the deployment_id option to the stage method' do
allow_any_instance_of(Egads::Stage).to receive(:stage).and_call_original
expect(stage_instance.options[:deployment_id]).to eq(true)
actual_options = subject.class_options.transform_values { |opt| { type: opt.type, default: opt.default, banner: opt.banner }}
_(actual_options).must_equal expected_options
end
end

0 comments on commit 7975462

Please sign in to comment.