From 26dee7157ae3b1efe428b21333f00084eaabff21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20R=C3=B8nn-Jensen?= Date: Mon, 13 Mar 2017 15:44:48 +0100 Subject: [PATCH 1/2] (chore) (refactor) pipe result of each gsub instead of modifying original Simpler to just pipe the result of each command to the next. --- test/markup_test.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/markup_test.rb b/test/markup_test.rb index 4c8fdf45..970f98d1 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -9,11 +9,10 @@ require 'nokogiri/diff' def normalize_html(text) - text.strip! - text.gsub!(/\s\s+/,' ') - text.gsub!(/\p{Pi}|\p{Pf}|"/u,'"') - text.gsub!("\u2026",'...') - text + text.strip + .gsub(/\s\s+/,' ') + .gsub!(/\p{Pi}|\p{Pf}|"/u,'"') + .gsub!("\u2026",'...') end def assert_html_equal(expected, actual, msg = nil) From a49b58c0b2eff699ea5c94f12168019cf78deba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20R=C3=B8nn-Jensen?= Date: Mon, 29 May 2017 11:58:28 +0200 Subject: [PATCH 2/2] Update all gsub since `gsub!` can return nil and fail --- test/markup_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/markup_test.rb b/test/markup_test.rb index 970f98d1..3cc1b998 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -11,8 +11,8 @@ def normalize_html(text) text.strip .gsub(/\s\s+/,' ') - .gsub!(/\p{Pi}|\p{Pf}|"/u,'"') - .gsub!("\u2026",'...') + .gsub(/\p{Pi}|\p{Pf}|"/u,'"') + .gsub("\u2026",'...') end def assert_html_equal(expected, actual, msg = nil)