Skip to content

Commit

Permalink
Update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Sep 17, 2024
1 parent 4908299 commit e49bc62
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions spec/tag_release_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@
subject

expect(@tag_and_release_output[:merge_or_delete_successful]).to be_truthy
# expect(Fastlane::Actions::TagReleaseAction).to have_received(:report_status).with("macos")
end

it "reports status when merge or delete failed" do
allow(Fastlane::Actions::TagReleaseAction).to receive(:merge_or_delete_branch).and_raise(StandardError)
subject
context "when merge or delete failed" do
before do
allow(Fastlane::Actions::TagReleaseAction).to receive(:merge_or_delete_branch).and_raise(StandardError)
end

expect(@tag_and_release_output[:merge_or_delete_successful]).to be_falsy
# expect(Fastlane::Actions::TagReleaseAction).to have_received(:report_status).with("macos")
it "reports status" do
subject
expect(@tag_and_release_output[:merge_or_delete_successful]).to be_falsy
end
end
end

Expand All @@ -94,7 +96,7 @@
end
end

shared_examples "expected" do |repo_name|
shared_examples "successful execution" do |repo_name|
let (:repo_name) { repo_name }

it "creates tag and github release" do
Expand Down Expand Up @@ -195,52 +197,52 @@
end
end

include_context "common setup"
include_context "local setup"

tag_contexts = ["create tag", "push tag"]
tag_contexts = ["when failed to create tag", "when failed to push tag"]
github_release_contexts = [
{ action: "fetch latest GitHub release", includes_latest_public_release_tag: false },
{ action: "generate GitHub release notes", includes_latest_public_release_tag: true },
{ action: "parse GitHub response", includes_latest_public_release_tag: true },
{ action: "create GitHub release", includes_latest_public_release_tag: true }
{ name: "when failed to fetch latest GitHub release", includes_latest_public_release_tag: false },
{ name: "when failed to generate GitHub release notes", includes_latest_public_release_tag: true },
{ name: "when failed to parse GitHub response", includes_latest_public_release_tag: true },
{ name: "when failed to create GitHub release", includes_latest_public_release_tag: true }
]

include_context "common setup"
include_context "local setup"

context "on ios" do
include_context "on ios"

context "for prerelease" do
include_context "for prerelease"
it_behaves_like "expected", "duckduckgo/ios"
it_behaves_like "successful execution", "duckduckgo/ios"

tag_contexts.each do |action|
context "when failed to #{action}" do
include_context "when failed to #{action}"
tag_contexts.each do |context_name|
context context_name do
include_context context_name
it_behaves_like "gracefully handling tagging error"
end
end

github_release_contexts.each do |context_data|
context "when failed to #{context_data[:action]}" do
include_context "when failed to #{context_data[:action]}"
context context_data[:name] do
include_context context_data[:name]
it_behaves_like "gracefully handling GitHub release error", context_data[:includes_latest_public_release_tag]
end
end

context "for public release" do
include_context "for public release"
it_behaves_like "expected", "duckduckgo/ios"
it_behaves_like "successful execution", "duckduckgo/ios"

tag_contexts.each do |action|
context "when failed to #{action}" do
include_context "when failed to #{action}"
tag_contexts.each do |context_name|
context context_name do
include_context context_name
it_behaves_like "gracefully handling tagging error"
end
end

github_release_contexts.each do |context_data|
context "when failed to #{context_data[:action]}" do
include_context "when failed to #{context_data[:action]}"
context context_data[:name] do
include_context context_data[:name]
it_behaves_like "gracefully handling GitHub release error", context_data[:includes_latest_public_release_tag]
end
end
Expand All @@ -252,37 +254,37 @@

context "for prerelease" do
include_context "for prerelease"
it_behaves_like "expected", "duckduckgo/macos-browser"
it_behaves_like "successful execution", "duckduckgo/macos-browser"

tag_contexts.each do |action|
context "when failed to #{action}" do
include_context "when failed to #{action}"
tag_contexts.each do |context_name|
context context_name do
include_context context_name
it_behaves_like "gracefully handling tagging error"
end
end

github_release_contexts.each do |context_data|
context "when failed to #{context_data[:action]}" do
include_context "when failed to #{context_data[:action]}"
context context_data[:name] do
include_context context_data[:name]
it_behaves_like "gracefully handling GitHub release error", context_data[:includes_latest_public_release_tag]
end
end
end

context "for public release" do
include_context "for public release"
it_behaves_like "expected", "duckduckgo/macos-browser"
it_behaves_like "successful execution", "duckduckgo/macos-browser"

tag_contexts.each do |action|
context "when failed to #{action}" do
include_context "when failed to #{action}"
tag_contexts.each do |context_name|
context context_name do
include_context context_name
it_behaves_like "gracefully handling tagging error"
end
end

github_release_contexts.each do |context_data|
context "when failed to #{context_data[:action]}" do
include_context "when failed to #{context_data[:action]}"
context context_data[:name] do
include_context context_data[:name]
it_behaves_like "gracefully handling GitHub release error", context_data[:includes_latest_public_release_tag]
end
end
Expand Down

0 comments on commit e49bc62

Please sign in to comment.