Skip to content

Commit

Permalink
main_command_spec: fix structure and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
amcinnes committed Nov 25, 2020
1 parent 5ac0574 commit 0c64d9e
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions spec/stackup/main_command_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
require "stackup/main_command"

describe Stackup::MainCommand do
context "change-set create --service-role-arn"
let(:mock_change_set) { double() }

before(:example) do
mock_stackup = double()
mock_stack = double()
allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
allow(mock_stackup).to receive(:stack).and_return(mock_stack)
allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
end

let(:mock_change_set) { double() }

before(:example) do
mock_stackup = double()
mock_stack = double()
allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
allow(mock_stackup).to receive(:stack).and_return(mock_stack)
allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
end

context "change-set create --service-role-arn" do
it "invokes stack.change_set.create with role arn passed through" do
expected_args = {
role_arn: "arn:aws:iam::000000000000:role/example"
Expand All @@ -23,32 +24,33 @@
"--template", "examples/template.yml",
"--service-role-arn", "arn:aws:iam::000000000000:role/example"])
end
end

context "change-set create" do
it "invokes stack.change_set.create with allow_empty_change_set nil" do
expected_args = {
allow_empty_change_set: nil
}
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))

Stackup::MainCommand.run("stackup", [
"STACK-NAME", "change-set", "create",
"--template", "examples/template.yml"])
end
end
context "change-set create" do
it "invokes stack.change_set.create with allow_empty_change_set nil" do
expected_args = {
allow_empty_change_set: nil
}
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))

context "change-set create --no-fail-on-empty-change-set" do
it "invokes stack.change_set.create with allow_empty_change_set true" do
expected_args = {
allow_empty_change_set: true
}
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))

Stackup::MainCommand.run("stackup", [
"STACK-NAME", "change-set", "create",
"--template", "examples/template.yml",
"--no-fail-on-empty-change-set"])
end
Stackup::MainCommand.run("stackup", [
"STACK-NAME", "change-set", "create",
"--template", "examples/template.yml"])
end
end

context "change-set create --no-fail-on-empty-change-set" do
it "invokes stack.change_set.create with allow_empty_change_set true" do
expected_args = {
allow_empty_change_set: true
}
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))

Stackup::MainCommand.run("stackup", [
"STACK-NAME", "change-set", "create",
"--template", "examples/template.yml",
"--no-fail-on-empty-change-set"])
end
end

end

0 comments on commit 0c64d9e

Please sign in to comment.