-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add max_retry_count & wait options to Command::Base#step
- Loading branch information
Showing
4 changed files
with
84 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,7 @@ RSpec/ExampleLength: | |
|
||
RSpec/MultipleExpectations: | ||
Enabled: false | ||
|
||
RSpec/NestedGroups: | ||
Enabled: true | ||
Max: 5 |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe Command::Base do | ||
subject(:command) { described_class.new(config) } | ||
|
||
let(:config) { instance_double(Command::Config) } | ||
|
||
around do |example| | ||
suppress_output { example.run } | ||
end | ||
|
||
describe "#step" do | ||
let(:message) { "test message" } | ||
|
||
context "with retry_on_failure: true" do | ||
let(:options) { { retry_on_failure: true, wait: 0 } } | ||
|
||
it "retries block 5 times by default" do | ||
run_count = 0 | ||
|
||
command.step(message, **options) do | ||
run_count += 1 | ||
false | ||
end | ||
|
||
expect(run_count).to eq 5 | ||
end | ||
|
||
context "with max_retry_count option" do | ||
let(:options) { super().merge(max_retry_count: 1) } | ||
|
||
it "retries block specified times" do | ||
run_count = 0 | ||
|
||
command.step(message, **options) do | ||
run_count += 1 | ||
false | ||
end | ||
|
||
expect(run_count).to eq 1 | ||
end | ||
end | ||
end | ||
|
||
context "with retry_on_failure: false" do | ||
let(:options) { { retry_on_failure: false } } | ||
|
||
it "does not retry block" do | ||
run_count = 0 | ||
|
||
command.step(message, **options) do | ||
run_count += 1 | ||
false | ||
end | ||
|
||
expect(run_count).to eq 1 | ||
end | ||
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