mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 04:40:09 +01:00
@benbalter review comments
This commit is contained in:
parent
775a2f2920
commit
f4b5e20cba
@ -3,22 +3,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'word wrapping' do
|
describe 'word wrapping' do
|
||||||
Dir["#{licenses_path}/*.txt"].each do |file|
|
licenses.each do |license|
|
||||||
context "the #{File.basename(file, '.txt')} license" do
|
context "the #{license['slug']} license" do
|
||||||
it 'does not wrap at line length 78' do
|
it 'wraps at line length 78' do
|
||||||
file_content = File.read(file, encoding: 'utf-8')
|
max_line = license['content'].lines.max_by { |line| line.chomp!.length }
|
||||||
license_text = file_content.match(/\A(?:---\n.*\n---\n+)?(.*)/m)[1]
|
msg = "Longest line is #{max_line.length} characters: #{max_line}"
|
||||||
max_line_length = 0
|
expect(max_line.length).to be <= 78, msg
|
||||||
max_line = ''
|
|
||||||
license_text.lines.each do |line|
|
|
||||||
line.chomp!
|
|
||||||
if line.length > max_line_length
|
|
||||||
max_line_length = line.length
|
|
||||||
max_line = line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
msg = "Longest line is #{max_line_length} characters: #{max_line}"
|
|
||||||
expect(max_line_length).to be <= 78, msg
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user