-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from chubchenko/enhancement/rubocop-suggestions
Add RuboCop suggestions
- Loading branch information
Showing
7 changed files
with
96 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :deploy do | ||
desc "Dummy for a successful deployment" | ||
task :finishing | ||
|
||
desc "Dummy for successful rollback" | ||
task :finishing_rollback | ||
|
||
desc "Dummy for failure deployment or rollback" | ||
task :failed | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "load:defaults" do | ||
it "adds the file to the linked files" do | ||
expect do | ||
Rake::Task["load:defaults"].invoke | ||
end.to change { Capistrano::Configuration.env.fetch(:linked_files) }.to(["config/slacky.yml"]) | ||
RSpec.describe "load", type: :task do | ||
describe "defaults" do | ||
it "adds the file to the linked files" do | ||
expect do | ||
Rake::Task["load:defaults"].invoke | ||
end.to change { Capistrano::Configuration.env.fetch(:linked_files) }.to(["config/slacky.yml"]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,107 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "slacky:updated" do | ||
it "slacky after a successful deployment" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
RSpec.describe "slacky", type: :task do | ||
describe "updated" do | ||
it "slacky after a successful deployment" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
|
||
Rake::Task["slacky:updated"].invoke | ||
Rake::Task["slacky:updated"].invoke | ||
|
||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :updated | ||
) | ||
end | ||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :updated | ||
) | ||
end | ||
|
||
it "invokes slacky:updated after deploy:finishing" do | ||
allow(Rake::Task["slacky:updated"]).to receive(:invoke) | ||
it "invokes slacky:updated after deploy:finishing" do | ||
allow(Rake::Task["slacky:updated"]).to receive(:invoke) | ||
|
||
Rake::Task["deploy:finishing"].execute | ||
Rake::Task["deploy:finishing"].execute | ||
|
||
expect(Rake::Task["slacky:updated"]).to have_received(:invoke) | ||
expect(Rake::Task["slacky:updated"]).to have_received(:invoke) | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe "slacky:reverted" do | ||
before { allow(Capistrano::Slacky::Command::CurrentRevision).to receive(:call) } | ||
describe "reverted" do | ||
before { allow(Capistrano::Slacky::Command::CurrentRevision).to receive(:call) } | ||
|
||
it "slacky after successful rollback" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
it "slacky after successful rollback" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
|
||
Rake::Task["slacky:reverted"].invoke | ||
Rake::Task["slacky:reverted"].invoke | ||
|
||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :reverted | ||
) | ||
end | ||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :reverted | ||
) | ||
end | ||
|
||
it "invokes slacky:reverted after deploy:finishing_rollback" do | ||
allow(Rake::Task["slacky:reverted"]).to receive(:invoke) | ||
it "invokes slacky:reverted after deploy:finishing_rollback" do | ||
allow(Rake::Task["slacky:reverted"]).to receive(:invoke) | ||
|
||
Rake::Task["deploy:finishing_rollback"].execute | ||
Rake::Task["deploy:finishing_rollback"].execute | ||
|
||
expect(Rake::Task["slacky:reverted"]).to have_received(:invoke) | ||
end | ||
expect(Rake::Task["slacky:reverted"]).to have_received(:invoke) | ||
end | ||
|
||
it "invokes slacky:ensure_current_revision before slacky:reverted" do | ||
expect(Rake::Task["slacky:reverted"].prerequisites).to match_array("ensure_current_revision") | ||
it "invokes slacky:ensure_current_revision before slacky:reverted" do | ||
expect(Rake::Task["slacky:reverted"].prerequisites).to match_array("ensure_current_revision") | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe "slacky:failed" do | ||
before do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
end | ||
describe "failed" do | ||
before do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
end | ||
|
||
it "Slacky after failure deployment or rollback" do | ||
Rake::Task["slacky:failed"].invoke | ||
it "Slacky after failure deployment or rollback" do | ||
Rake::Task["slacky:failed"].invoke | ||
|
||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :failed | ||
) | ||
end | ||
expect(Capistrano::Slacky::Runner).to have_received(:call).with( | ||
action: :failed | ||
) | ||
end | ||
|
||
it "invokes slacky:failed after deploy:failed" do | ||
allow(Rake::Task["slacky:failed"]).to receive(:invoke) | ||
it "invokes slacky:failed after deploy:failed" do | ||
allow(Rake::Task["slacky:failed"]).to receive(:invoke) | ||
|
||
Rake::Task["deploy:failed"].execute | ||
Rake::Task["deploy:failed"].execute | ||
|
||
expect(Rake::Task["slacky:failed"]).to have_received(:invoke) | ||
expect(Rake::Task["slacky:failed"]).to have_received(:invoke) | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe "slacky:ping" do | ||
it "pings all available tasks" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
describe "ping" do | ||
it "pings all available tasks" do | ||
allow(Capistrano::Slacky::Runner).to receive(:call) | ||
|
||
Rake::Task["slacky:ping"].invoke | ||
Rake::Task["slacky:ping"].invoke | ||
|
||
expect(Capistrano::Slacky::Runner).to have_received(:call).exactly(3).times | ||
expect(Capistrano::Slacky::Runner).to have_received(:call).exactly(3).times | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe "slacky:ensure_current_revision" do | ||
context "when :current_revision is empty" do | ||
before { allow(Capistrano::Slacky::Command::CurrentRevision).to receive(:call).and_return("2eab27b") } | ||
describe "ensure_current_revision" do | ||
context "when :current_revision is empty" do | ||
before { allow(Capistrano::Slacky::Command::CurrentRevision).to receive(:call).and_return("2eab27b") } | ||
|
||
around do |example| | ||
previous = Capistrano::Configuration.env.delete(:current_revision) | ||
example.run | ||
Capistrano::Configuration.env.set(:current_revision, previous) | ||
end | ||
around do |example| | ||
previous = Capistrano::Configuration.env.delete(:current_revision) | ||
example.run | ||
Capistrano::Configuration.env.set(:current_revision, previous) | ||
end | ||
|
||
it "sets :current_revision" do | ||
Rake::Task["slacky:ensure_current_revision"].execute | ||
it "sets :current_revision" do | ||
Rake::Task["slacky:ensure_current_revision"].execute | ||
|
||
expect(Capistrano::Configuration.env.fetch(:current_revision)).to eq("2eab27b") | ||
expect(Capistrano::Configuration.env.fetch(:current_revision)).to eq("2eab27b") | ||
end | ||
end | ||
end | ||
|
||
context "when :current_revision is not empty" do | ||
it "does not set :current_revision" do | ||
Rake::Task["slacky:ensure_current_revision"].execute | ||
context "when :current_revision is not empty" do | ||
it "does not set :current_revision" do | ||
Rake::Task["slacky:ensure_current_revision"].execute | ||
|
||
expect(Capistrano::Configuration.env.fetch(:current_revision)).to eq("02c4c96") | ||
expect(Capistrano::Configuration.env.fetch(:current_revision)).to eq("02c4c96") | ||
end | ||
end | ||
end | ||
end |