Skip to content

Commit

Permalink
Merge pull request #69 from rubocop/fix-project-spec
Browse files Browse the repository at this point in the history
Improve for project_spec
  • Loading branch information
ydah authored Sep 19, 2023
2 parents 7bef12a + 56d339d commit d020309
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## 2.18.0 (2023-04-21)

- Fix an offense message for `Capybara/SpecificFinders`. ([@ydah])
- Expand `Capybara/NegationMatcher` to support `have_content` ([@OskarsEzerins])
- Expand `Capybara/NegationMatcher` to support `have_content`. ([@OskarsEzerins])
- Fix an incorrect autocorrect for `Capybara/CurrentPathExpectation` when matcher's argument is a method with a argument and no parentheses. ([@ydah])

## 2.17.1 (2023-02-13)
Expand Down
46 changes: 11 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 All @@ -91,6 +61,12 @@
it 'ends with a punctuation' do
expect(bodies).to all(match(/[.!]$/))
end

it 'does not use consecutive whitespaces' do
entries.each do |entry|
expect(entry).not_to match(/\s{2,}/)
end
end
end
end
end

0 comments on commit d020309

Please sign in to comment.