Skip to content

Commit

Permalink
refactor: reorganise tests for greater readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Lay committed Nov 8, 2019
1 parent 66a088c commit 372d5b8
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions spec/conventional_changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,106 +36,106 @@ def execute_lane_test_no_header_slack
expect(execute_lane_test).to eq(result)
end

it "should skip the header if display_title is false" do
it "should create sections in Slack format" do
commits = [
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
"docs: sub|body|long_hash|short_hash|Jiri Otahal|time",
"fix: sub||long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "### Bug fixes\n- sub ([short_hash](/long_hash))\n\n### BREAKING CHANGES\n- Test ([short_hash](/long_hash))"
result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*Documentation*\n- sub (</long_hash|short_hash>)"

expect(execute_lane_test_no_header).to eq(result)
expect(execute_lane_test_slack).to eq(result)
end

it "should display breaking change in markdown format" do
it "should skip the header if display_title is false" do
commits = [
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- sub ([short_hash](/long_hash))\n\n### BREAKING CHANGES\n- Test ([short_hash](/long_hash))"
result = "### Bug fixes\n- sub ([short_hash](/long_hash))\n\n### BREAKING CHANGES\n- Test ([short_hash](/long_hash))"

expect(execute_lane_test).to eq(result)
expect(execute_lane_test_no_header).to eq(result)
end

it "should display scopes in markdown format" do
it "should skip the header if display_title is false in Slack format" do
commits = [
"fix(test): sub||long_hash|short_hash|Jiri Otahal|time"
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- **test:** sub ([short_hash](/long_hash))"
result = "*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*BREAKING CHANGES*\n- Test (</long_hash|short_hash>)"

expect(execute_lane_test).to eq(result)
expect(execute_lane_test_no_header_slack).to eq(result)
end

it "should skip merge in markdown format" do
it "should display a breaking change in markdown format" do
commits = [
"Merge ...||long_hash|short_hash|Jiri Otahal|time",
"Custom Merge...||long_hash|short_hash|Jiri Otahal|time",
"fix(test): sub||long_hash|short_hash|Jiri Otahal|time"
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- **test:** sub ([short_hash](/long_hash))\n\n### Other work\n- Custom Merge... ([short_hash](/long_hash))"
result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- sub ([short_hash](/long_hash))\n\n### BREAKING CHANGES\n- Test ([short_hash](/long_hash))"

expect(execute_lane_test).to eq(result)
end

it "should create sections in Slack format" do
it "should display a breaking change in Slack format" do
commits = [
"docs: sub|body|long_hash|short_hash|Jiri Otahal|time",
"fix: sub||long_hash|short_hash|Jiri Otahal|time"
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*Documentation*\n- sub (</long_hash|short_hash>)"
result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*BREAKING CHANGES*\n- Test (</long_hash|short_hash>)"

expect(execute_lane_test_slack).to eq(result)
end

it "should skip the header if display_title is false in Slack format" do
it "should display scopes in markdown format" do
commits = [
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
"fix(test): sub||long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*BREAKING CHANGES*\n- Test (</long_hash|short_hash>)"
result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- **test:** sub ([short_hash](/long_hash))"

expect(execute_lane_test_no_header_slack).to eq(result)
expect(execute_lane_test).to eq(result)
end

it "should display breaking change in Slack format" do
it "should display scopes in Slack format" do
commits = [
"fix: sub|BREAKING CHANGE: Test|long_hash|short_hash|Jiri Otahal|time"
"fix(test): sub||long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- sub (</long_hash|short_hash>)\n\n*BREAKING CHANGES*\n- Test (</long_hash|short_hash>)"
result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- *test:* sub (</long_hash|short_hash>)"

expect(execute_lane_test_slack).to eq(result)
end

it "should display scopes in Slack format" do
it "should skip merge commits in markdown format" do
commits = [
"Merge ...||long_hash|short_hash|Jiri Otahal|time",
"Custom Merge...||long_hash|short_hash|Jiri Otahal|time",
"fix(test): sub||long_hash|short_hash|Jiri Otahal|time"
]
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))

result = "*1.0.2 (2019-05-25)*\n\n*Bug fixes*\n- *test:* sub (</long_hash|short_hash>)"
result = "# 1.0.2 (2019-05-25)\n\n### Bug fixes\n- **test:** sub ([short_hash](/long_hash))\n\n### Other work\n- Custom Merge... ([short_hash](/long_hash))"

expect(execute_lane_test_slack).to eq(result)
expect(execute_lane_test).to eq(result)
end

it "should skip merge in Slack format" do
it "should skip merge commits in Slack format" do
commits = [
"Merge ...||long_hash|short_hash|Jiri Otahal|time",
"Custom Merge...||long_hash|short_hash|Jiri Otahal|time",
Expand Down

0 comments on commit 372d5b8

Please sign in to comment.