Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve for project_spec #69

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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