From f4b5e20cba5e5d07cda51978e6e614b2b57dae99 Mon Sep 17 00:00:00 2001 From: Mike Linksvayer Date: Mon, 20 Nov 2017 12:56:03 -0800 Subject: [PATCH] @benbalter review comments --- spec/license_wrap_spec.rb | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/spec/license_wrap_spec.rb b/spec/license_wrap_spec.rb index c687a77..9ab174d 100644 --- a/spec/license_wrap_spec.rb +++ b/spec/license_wrap_spec.rb @@ -3,22 +3,12 @@ require 'spec_helper' describe 'word wrapping' do - Dir["#{licenses_path}/*.txt"].each do |file| - context "the #{File.basename(file, '.txt')} license" do - it 'does not wrap at line length 78' do - file_content = File.read(file, encoding: 'utf-8') - license_text = file_content.match(/\A(?:---\n.*\n---\n+)?(.*)/m)[1] - max_line_length = 0 - 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 + licenses.each do |license| + context "the #{license['slug']} license" do + it 'wraps at line length 78' do + max_line = license['content'].lines.max_by { |line| line.chomp!.length } + msg = "Longest line is #{max_line.length} characters: #{max_line}" + expect(max_line.length).to be <= 78, msg end end end