Skip to content

Commit

Permalink
Fix errors in changelog_spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Sep 19, 2023
1 parent b99bf78 commit 287bc97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- Add `AllowedIdentifiers` and `AllowedPatterns` configuration option to `RSpec/IndexedLet`. ([@ydah])
- Fix `RSpec/NamedSubject` when block has no body. ([@splattael])
- Fix `RSpec/LetBeforeExamples` autocorrect incompatible with `RSpec/ScatteredLet` autocorrect. ([@ydah])
- Update `RSpec/Focus` to support `shared_context` and `shared_examples` ([@tmaier])
- Update `RSpec/Focus` to support `shared_context` and `shared_examples`. ([@tmaier])

## 2.22.0 (2023-05-06)

Expand All @@ -56,9 +56,9 @@
- Add support `be_status` style for `RSpec/Rails/HttpStatus`. ([@ydah])
- Add support for shared example groups to `RSpec/EmptyLineAfterExampleGroup`. ([@pirj])
- Add support for `RSpec/HaveHttpStatus` when using `response.code`. ([@ydah])
- Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions` ([@mvz])
- Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions`. ([@mvz])
- Fix a false positive for `RSpec/DescribedClassModuleWrapping` when RSpec.describe numblock is nested within a module. ([@ydah])
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on ([@dmitrytsepelev])
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on. ([@dmitrytsepelev])
- Fix a false positive for `RSpec/PendingWithoutReason` when pending/skip has a reason inside an example group. ([@ydah])
- Fix a false negative for `RSpec/RedundantAround` when redundant numblock `around`. ([@ydah])
- Change `RSpec/ContainExactly` to ignore calls with no arguments, and change `RSpec/MatchArray` to ignore calls with an empty array literal argument. ([@ydah], [@bquorning])
Expand Down Expand Up @@ -111,7 +111,7 @@
- Improved processing speed for `RSpec/Be`, `RSpec/ExpectActual`, `RSpec/ImplicitExpect`, `RSpec/MessageSpies`, `RSpec/PredicateMatcher` and `RSpec/Rails/HaveHttpStatus`. ([@ydah])
- Fix wrong autocorrection in `n_times` style on `RSpec/FactoryBot/CreateList`. ([@r7kamura])
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` when using `generate` with multiple arguments. ([@ydah])
- Mark `RSpec/BeEq` as `Safe: false` ([@r7kamura])
- Mark `RSpec/BeEq` as `Safe: false`. ([@r7kamura])
- Add `RSpec/DuplicatedMetadata` cop. ([@r7kamura])
- Mark `RSpec/BeEql` as `Safe: false`. ([@r7kamura])
- Add `RSpec/PendingWithoutReason` cop. ([@r7kamura])
Expand Down
40 changes: 5 additions & 35 deletions spec/project/changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,23 @@
end

describe 'entry' do
subject(:entries) { lines.grep(/^\*/).map(&:chomp) }
subject(:entries) { lines.grep(/^-/).map(&:chomp) }

let(:lines) { changelog.each_line }

it 'has a whitespace between the * and the body' do
expect(entries).to all(match(/^\* \S/))
it 'has some entries' do
expect(entries).not_to be_empty
end

it 'has a link to the contributors at the end' do
expect(entries).to all(match(/\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/))
end

describe 'link to related issue on github' do
let(:issues) do
entries.map do |entry|
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^)]+)\)/)
end.compact
end

it 'has an issue number prefixed with #' do
issues.each do |issue|
expect(issue[:number]).to match(/^#\d+$/)
end
end

it 'has a valid URL' do
issues.each do |issue|
number = issue[:number].gsub(/\D/, '')
pattern = %r{^https://github\.com/.+/.+/(?:issues|pull)/#{number}$}
expect(issue[:url]).to match(pattern)
end
end

it 'has a colon and a whitespace at the end' do
entries_including_issue_link = entries.select do |entry|
entry.match(/^\*\s*\[/)
end

expect(entries_including_issue_link).to all(include('): '))
end
expect(entries).to all(match(/\(\[@\S+\](?:, \[@\S+\])*\)$/))
end

describe 'body' do
let(:bodies) do
entries.map do |entry|
entry
.sub(/^\*\s*(?:\[.+?\):\s*)?/, '')
.sub(/^-\s*(?:\[.+?\):\s*)?/, '')
.sub(/\s*\([^)]+\)$/, '')
end
end
Expand Down

0 comments on commit 287bc97

Please sign in to comment.