From f5a0db9dccb737d9ebd90a87e9d9a4e9a6b481f0 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 2 Jun 2016 17:08:21 -0700 Subject: [PATCH] Rubocop: use %r for all regular expressions. --- .rubocop.yml | 2 +- features/step_definitions.rb | 54 +++++++++---------- features/support/helpers.rb | 4 +- lib/jekyll/commands/doctor.rb | 2 +- lib/jekyll/commands/serve/servlet.rb | 4 +- lib/jekyll/converters/markdown.rb | 2 +- .../converters/markdown/kramdown_parser.rb | 2 +- .../converters/markdown/redcarpet_parser.rb | 2 +- lib/jekyll/excerpt.rb | 2 +- lib/jekyll/log_adapter.rb | 2 +- lib/jekyll/readers/data_reader.rb | 6 +-- lib/jekyll/tags/highlight.rb | 6 +-- lib/jekyll/tags/include.rb | 16 +++--- lib/jekyll/tags/post_url.rb | 2 +- lib/jekyll/theme_builder.rb | 2 +- lib/jekyll/utils/ansi.rb | 2 +- lib/jekyll/utils/platforms.rb | 4 +- test/test_convertible.rb | 10 ++-- test/test_entry_filter.rb | 2 +- test/test_liquid_renderer.rb | 4 +- test/test_new_command.rb | 6 +-- test/test_page.rb | 2 +- test/test_tags.rb | 44 +++++++-------- 23 files changed, 91 insertions(+), 91 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 982ec43c..fbe07db3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -121,7 +121,7 @@ Style/RedundantReturn: Style/RedundantSelf: Enabled: false Style/RegexpLiteral: - EnforcedStyle: slashes + EnforcedStyle: percent_r Style/RescueModifier: Enabled: false Style/SignalException: diff --git a/features/step_definitions.rb b/features/step_definitions.rb index ce42725d..731f8b7b 100644 --- a/features/step_definitions.rb +++ b/features/step_definitions.rb @@ -14,7 +14,7 @@ end # -Given(/^I have a blank site in "(.*)"$/) do |path| +Given(%r!^I have a blank site in "(.*)"$!) do |path| unless File.exist?(path) then FileUtils.mkdir_p(path) end @@ -22,13 +22,13 @@ end # -Given(/^I do not have a "(.*)" directory$/) do |path| +Given(%r!^I do not have a "(.*)" directory$!) do |path| Paths.test_dir.join(path).directory? end # -Given(/^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/) do |file, key, value, text| +Given(%r!^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$!) do |file, key, value, text| File.write(file, Jekyll::Utils.strip_heredoc(<<-DATA)) --- #{key || "layout"}: #{value || "nil"} @@ -40,13 +40,13 @@ end # -Given(/^I have an? "(.*)" file that contains "(.*)"$/) do |file, text| +Given(%r!^I have an? "(.*)" file that contains "(.*)"$!) do |file, text| File.write(file, text) end # -Given(/^I have an? (.*) (layout|theme) that contains "(.*)"$/) do |name, type, text| +Given(%r!^I have an? (.*) (layout|theme) that contains "(.*)"$!) do |name, type, text| folder = type == "layout" ? "_layouts" : "_theme" destination_file = Pathname.new(File.join(folder, "#{name}.html")) @@ -56,13 +56,13 @@ end # -Given(/^I have an? "(.*)" file with content:$/) do |file, text| +Given(%r!^I have an? "(.*)" file with content:$!) do |file, text| File.write(file, text) end # -Given(/^I have an? (.*) directory$/) do |dir| +Given(%r!^I have an? (.*) directory$!) do |dir| unless File.directory?(dir) then FileUtils.mkdir_p(dir) end @@ -70,7 +70,7 @@ end # -Given(/^I have the following (draft|page|post)s?(?: (in|under) "([^"]+)")?:$/) do |status, direction, folder, table| +Given(%r!^I have the following (draft|page|post)s?(?: (in|under) "([^"]+)")?:$!) do |status, direction, folder, table| table.hashes.each do |input_hash| title = slug(input_hash["title"]) ext = input_hash["type"] || "markdown" @@ -92,7 +92,7 @@ end # -Given(/^I have a configuration file with "(.*)" set to "(.*)"$/) do |key, value| +Given(%r!^I have a configuration file with "(.*)" set to "(.*)"$!) do |key, value| config = \ if source_dir.join("_config.yml").exist? SafeYAML.load_file(source_dir.join("_config.yml")) @@ -105,7 +105,7 @@ end # -Given(/^I have a configuration file with:$/) do |table| +Given(%r!^I have a configuration file with:$!) do |table| table.hashes.each do |row| step %(I have a configuration file with "#{row["key"]}" set to "#{row["value"]}") end @@ -113,7 +113,7 @@ end # -Given(/^I have a configuration file with "([^\"]*)" set to:$/) do |key, table| +Given(%r!^I have a configuration file with "([^\"]*)" set to:$!) do |key, table| File.open("_config.yml", "w") do |f| f.write("#{key}:\n") table.hashes.each do |row| @@ -124,20 +124,20 @@ end # -Given(/^I have fixture collections$/) do +Given(%r!^I have fixture collections$!) do FileUtils.cp_r Paths.source_dir.join("test", "source", "_methods"), source_dir FileUtils.cp_r Paths.source_dir.join("test", "source", "_thanksgiving"), source_dir end # -Given(/^I wait (\d+) second(s?)$/) do |time, _| +Given(%r!^I wait (\d+) second(s?)$!) do |time, _| sleep(time.to_f) end # -When(/^I run jekyll(.*)$/) do |args| +When(%r!^I run jekyll(.*)$!) do |args| run_jekyll(args) if args.include?("--verbose") || ENV["DEBUG"] $stderr.puts "\n#{jekyll_run_output}\n" @@ -146,7 +146,7 @@ end # -When(/^I run bundle(.*)$/) do |args| +When(%r!^I run bundle(.*)$!) do |args| run_bundle(args) if args.include?("--verbose") || ENV["DEBUG"] $stderr.puts "\n#{jekyll_run_output}\n" @@ -155,7 +155,7 @@ end # -When(/^I change "(.*)" to contain "(.*)"$/) do |file, text| +When(%r!^I change "(.*)" to contain "(.*)"$!) do |file, text| File.open(file, "a") do |f| f.write(text) end @@ -163,13 +163,13 @@ end # -When(/^I delete the file "(.*)"$/) do |file| +When(%r!^I delete the file "(.*)"$!) do |file| File.delete(file) end # -Then(/^the (.*) directory should +(not )?exist$/) do |dir, negative| +Then(%r!^the (.*) directory should +(not )?exist$!) do |dir, negative| if negative.nil? expect(Pathname.new(dir)).to exist else @@ -178,7 +178,7 @@ Then(/^the (.*) directory should +(not )?exist$/) do |dir, negative| end # -Then(/^I should (not )?see "(.*)" in "(.*)"$/) do |negative, text, file| +Then(%r!^I should (not )?see "(.*)" in "(.*)"$!) do |negative, text, file| step %(the "#{file}" file should exist) regexp = Regexp.new(text, Regexp::MULTILINE) if negative.nil? || negative.empty? @@ -190,20 +190,20 @@ end # -Then(/^I should see exactly "(.*)" in "(.*)"$/) do |text, file| +Then(%r!^I should see exactly "(.*)" in "(.*)"$!) do |text, file| step %(the "#{file}" file should exist) expect(file_contents(file).strip).to eq text end # -Then(/^I should see escaped "(.*)" in "(.*)"$/) do |text, file| +Then(%r!^I should see escaped "(.*)" in "(.*)"$!) do |text, file| step %(I should see "#{Regexp.escape(text)}" in "#{file}") end # -Then(/^the "(.*)" file should +(not )?exist$/) do |file, negative| +Then(%r!^the "(.*)" file should +(not )?exist$!) do |file, negative| if negative.nil? expect(Pathname.new(file)).to exist else @@ -213,19 +213,19 @@ end # -Then(/^I should see today's time in "(.*)"$/) do |file| +Then(%r!^I should see today's time in "(.*)"$!) do |file| step %(I should see "#{seconds_agnostic_time(Time.now)}" in "#{file}") end # -Then(/^I should see today's date in "(.*)"$/) do |file| +Then(%r!^I should see today's date in "(.*)"$!) do |file| step %(I should see "#{Date.today}" in "#{file}") end # -Then(/^I should (not )?see "(.*)" in the build output$/) do |negative, text| +Then(%r!^I should (not )?see "(.*)" in the build output$!) do |negative, text| if negative.nil? || negative.empty? expect(jekyll_run_output).to match Regexp.new(text) else @@ -235,12 +235,12 @@ end # -Then(/^I should get a zero exit(?:\-| )status$/) do +Then(%r!^I should get a zero exit(?:\-| )status$!) do step %(I should see "EXIT STATUS: 0" in the build output) end # -Then(/^I should get a non-zero exit(?:\-| )status$/) do +Then(%r!^I should get a non-zero exit(?:\-| )status$!) do step %(I should not see "EXIT STATUS: 0" in the build output) end diff --git a/features/support/helpers.rb b/features/support/helpers.rb index 29333075..e7381a36 100644 --- a/features/support/helpers.rb +++ b/features/support/helpers.rb @@ -36,7 +36,7 @@ def file_content_from_hash(input_hash) Jekyll::Utils.strip_heredoc(<<-EOF) --- #{matter.gsub( - /\n/, "\n " + %r!\n!, "\n " )} --- #{content} @@ -121,7 +121,7 @@ end def slug(title = nil) if !title then Time.now.strftime("%s%9N") # nanoseconds since the Epoch - else title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, "-") + else title.downcase.gsub(%r![^\w]!, " ").strip.gsub(%r!\s+!, "-") end end diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 0c4f52f8..4c750b1c 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -63,7 +63,7 @@ module Jekyll def fsnotify_buggy?(_site) return true unless Utils::Platforms.osx? if Dir.pwd != `pwd`.strip - Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ") + Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ") We have detected that there might be trouble using fsevent on your operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug) for possible work arounds or you can work around it immediately diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index 5f258e6e..d0dd22af 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -37,10 +37,10 @@ module Jekyll private def validate_and_ensure_charset(_req, res) - key = res.header.keys.grep(/content-type/i).first + key = res.header.keys.grep(%r!content-type!i).first typ = res.header[key] - unless typ =~ /;\s*charset=/ + unless typ =~ %r!;\s*charset=! res.header[key] = "#{typ}; charset=#{@jekyll_opts["encoding"]}" end end diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index ab886d06..c718d539 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -93,7 +93,7 @@ module Jekyll private def custom_class_allowed?(parser_name) - parser_name !~ /[^A-Za-z0-9_]/ && self.class.constants.include?( + parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?( parser_name.to_sym ) end diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index 6e65d43c..932cf24e 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -86,7 +86,7 @@ module Jekyll private def strip_coderay_prefix(hash) hash.each_with_object({}) do |(key, val), hsh| - cleaned_key = key.gsub(/\Acoderay_/, "") + cleaned_key = key.gsub(%r!\Acoderay_!, "") if key != cleaned_key Jekyll::Deprecator.deprecation_message( diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb index 8e759385..b5ec99f5 100644 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ b/lib/jekyll/converters/markdown/redcarpet_parser.rb @@ -3,7 +3,7 @@ class Jekyll::Converters::Markdown::RedcarpetParser def add_code_tags(code, lang) code = code.to_s code = code.sub( - /
/,
+        %r!
!,
         "
"
       )
       code = code.sub(%r!
!, "
") diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 8fef70ed..2d53307e 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -117,7 +117,7 @@ module Jekyll if tail.empty? head else - "" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n") + "" << head << "\n\n" << tail.scan(%r!^\[[^\]]+\]:.+$!).join("\n") end end end diff --git a/lib/jekyll/log_adapter.rb b/lib/jekyll/log_adapter.rb index 8ac67451..70173b91 100644 --- a/lib/jekyll/log_adapter.rb +++ b/lib/jekyll/log_adapter.rb @@ -98,7 +98,7 @@ module Jekyll # # Returns the formatted message def message(topic, message) - msg = formatted_topic(topic) + message.to_s.gsub(/\s+/, " ") + msg = formatted_topic(topic) + message.to_s.gsub(%r!\s+!, " ") messages << msg msg end diff --git a/lib/jekyll/readers/data_reader.rb b/lib/jekyll/readers/data_reader.rb index e7e46bdc..4c6495fd 100644 --- a/lib/jekyll/readers/data_reader.rb +++ b/lib/jekyll/readers/data_reader.rb @@ -62,9 +62,9 @@ module Jekyll end def sanitize_filename(name) - name.gsub!(/[^\w\s-]+/, "") - name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2') - name.gsub(/\s+/, "_") + name.gsub!(%r![^\w\s-]+!, "") + name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2') + name.gsub(%r!\s+!, "_") end end end diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index af2a1e10..952fc9b4 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -8,7 +8,7 @@ module Jekyll # forms: name, name=value, or name="" # # is a space-separated list of numbers - SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$/ + SYNTAX = %r!^([a-zA-Z0-9.+#-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$! def initialize(tag_name, markup, tokens) super @@ -29,7 +29,7 @@ eos def render(context) prefix = context["highlighter_prefix"] || "" suffix = context["highlighter_suffix"] || "" - code = super.to_s.gsub(/\A(\n|\r)+|(\n|\r)+\z/, "") + code = super.to_s.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "") is_safe = !!context.registers[:site].safe @@ -67,7 +67,7 @@ eos options = {} unless input.empty? # Split along 3 possible forms -- key="", key=value, or key - input.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt| + input.scan(%r!(?:\w="[^"]*"|\w=\w|\w)+!) do |opt| key, value = opt.split("=") # If a quoted list, convert to array if value && value.include?("\"") diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index b1b02981..67461750 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -12,14 +12,14 @@ module Jekyll end class IncludeTag < Liquid::Tag - VALID_SYNTAX = / + VALID_SYNTAX = %r! ([\w-]+)\s*=\s* (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+)) - /x - VARIABLE_SYNTAX = / + !x + VARIABLE_SYNTAX = %r! (?[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+) (?.*) - /x + !x def initialize(tag_name, markup, tokens) super @@ -28,7 +28,7 @@ module Jekyll @file = matched["variable"].strip @params = matched["params"].strip else - @file, @params = markup.strip.split(/\s+/, 2) + @file, @params = markup.strip.split(%r!\s+!, 2) end validate_params if @params @tag_name = tag_name @@ -46,9 +46,9 @@ module Jekyll markup = markup[match.end(0)..-1] value = if match[2] - match[2].gsub(/\\"/, '"') + match[2].gsub(%r!\\"!, '"') elsif match[3] - match[3].gsub(/\\'/, "'") + match[3].gsub(%r!\\'!, "'") elsif match[4] context[match[4]] end @@ -74,7 +74,7 @@ eos end def validate_params - full_valid_syntax = /\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z/ + full_valid_syntax = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z! unless @params =~ full_valid_syntax raise ArgumentError, <<-eos Invalid syntax for include tag: diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 2154c0cd..04c1ef29 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -14,7 +14,7 @@ module Jekyll "'#{name}' does not contain valid date and/or title." end - @name_regex = /^#{path}#{date}-#{slug}\.[^.]+/ + @name_regex = %r!^#{path}#{date}-#{slug}\.[^.]+! end def post_date diff --git a/lib/jekyll/theme_builder.rb b/lib/jekyll/theme_builder.rb index 041faafe..5f834250 100644 --- a/lib/jekyll/theme_builder.rb +++ b/lib/jekyll/theme_builder.rb @@ -6,7 +6,7 @@ class Jekyll::ThemeBuilder attr_reader :name, :path def initialize(theme_name) - @name = theme_name.to_s.tr(" ", "_").gsub(/_+/, "_") + @name = theme_name.to_s.tr(" ", "_").gsub(%r!_+!, "_") @path = Pathname.new(File.expand_path(name, Dir.pwd)) end diff --git a/lib/jekyll/utils/ansi.rb b/lib/jekyll/utils/ansi.rb index 715cb277..4be163c5 100644 --- a/lib/jekyll/utils/ansi.rb +++ b/lib/jekyll/utils/ansi.rb @@ -8,7 +8,7 @@ module Jekyll extend self ESCAPE = format("%c", 27) - MATCH = /#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix + MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix COLORS = { :red => 31, :green => 32, diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index d431021f..b9455936 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -17,8 +17,8 @@ module Jekyll # platforms. This is mostly useful for `jekyll doctor` and for testing # where we kick off certain tests based on the platform. - { :windows? => /mswin|mingw|cygwin/, :linux? => /linux/, \ - :osx? => /darwin|mac os/, :unix? => /solaris|bsd/ }.each do |k, v| + { :windows? => %r!mswin|mingw|cygwin!, :linux? => %r!linux!, \ + :osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v| define_method k do !!( RbConfig::CONFIG["host_os"] =~ v diff --git a/test/test_convertible.rb b/test/test_convertible.rb index 4509ed36..0280946f 100644 --- a/test/test_convertible.rb +++ b/test/test_convertible.rb @@ -29,8 +29,8 @@ class TestConvertible < JekyllUnitTest ret = @convertible.read_yaml(@base, name) assert_equal({}, ret) end - assert_match(/YAML Exception|syntax error|Error reading file/, out) - assert_match(/#{File.join(@base, name)}/, out) + assert_match(%r!YAML Exception|syntax error|Error reading file!, out) + assert_match(%r!#{File.join(@base, name)}!, out) end should "not allow ruby objects in yaml" do @@ -46,8 +46,8 @@ class TestConvertible < JekyllUnitTest ret = @convertible.read_yaml(@base, name, :encoding => "utf-8") assert_equal({}, ret) end - assert_match(/invalid byte sequence in UTF-8/, out) - assert_match(/#{File.join(@base, name)}/, out) + assert_match(%r!invalid byte sequence in UTF-8!, out) + assert_match(%r!#{File.join(@base, name)}!, out) end should "parse the front-matter but show an error if permalink is empty" do @@ -61,7 +61,7 @@ class TestConvertible < JekyllUnitTest out = capture_stderr do @convertible.read_yaml(@base, "front_matter.erb") end - refute_match(/Invalid permalink/, out) + refute_match(%r!Invalid permalink!, out) end end end diff --git a/test/test_entry_filter.rb b/test/test_entry_filter.rb index 0b1d7134..eed24567 100644 --- a/test/test_entry_filter.rb +++ b/test/test_entry_filter.rb @@ -17,7 +17,7 @@ class TestEntryFilter < JekyllUnitTest should "allow regexp filtering" do files = %w(README.md) @site.exclude = [ - /README/ + %r!README! ] assert_empty @site.reader.filter_entries( diff --git a/test/test_liquid_renderer.rb b/test/test_liquid_renderer.rb index f6ab34d2..7d429c52 100644 --- a/test/test_liquid_renderer.rb +++ b/test/test_liquid_renderer.rb @@ -14,8 +14,8 @@ class TestLiquidRenderer < JekyllUnitTest # rubocop:disable Metrics/LineLength expected = [ - /^Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$/, - /^-+\++-+\++-+\++-+$/, + %r!^Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$!, + %r!^-+\++-+\++-+\++-+$!, %r!^_posts/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$! ] # rubocop:enable Metrics/LineLength diff --git a/test/test_new_command.rb b/test/test_new_command.rb index e0209400..7ab638fd 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -34,8 +34,8 @@ class TestNewCommand < JekyllUnitTest refute_exist @full_path capture_stdout { Jekyll::Commands::New.process(@args) } assert_exist gemfile - assert_match(/gem "jekyll", "#{Jekyll::VERSION}"/, File.read(gemfile)) - assert_match(/gem "github-pages"/, File.read(gemfile)) + assert_match(%r!gem "jekyll", "#{Jekyll::VERSION}"!, File.read(gemfile)) + assert_match(%r!gem "github-pages"!, File.read(gemfile)) end should "display a success message" do @@ -91,7 +91,7 @@ class TestNewCommand < JekyllUnitTest should "force created folder" do capture_stdout { Jekyll::Commands::New.process(@args) } output = capture_stdout { Jekyll::Commands::New.process(@args, "--force") } - assert_match(/New jekyll site installed in/, output) + assert_match(%r!New jekyll site installed in!, output) end end diff --git a/test/test_page.rb b/test/test_page.rb index 5b4aabeb..9b27af7f 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -313,7 +313,7 @@ class TestPage < JekyllUnitTest page.write(dest_dir) assert_equal "/sitemap.xml", page.url - assert_nil page.url[/\.html$/] + assert_nil page.url[%r!\.html$!] assert File.directory?(dest_dir) assert_exist dest_dir("sitemap.xml") end diff --git a/test/test_tags.rb b/test/test_tags.rb index 736d60d6..6b8fe8db 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -177,7 +177,7 @@ CONTENT end should "not cause a markdown error" do - refute_match(/markdown\-html\-error/, @result) + refute_match(%r!markdown\-html\-error!, @result) end should "render markdown with pygments" do @@ -544,7 +544,7 @@ CONTENT end should "not cause an error" do - refute_match(/markdown\-html\-error/, @result) + refute_match(%r!markdown\-html\-error!, @result) end should "have the url to the \"complex\" post from 2008-11-21" do @@ -573,7 +573,7 @@ CONTENT end should "not cause an error" do - refute_match(/markdown\-html\-error/, @result) + refute_match(%r!markdown\-html\-error!, @result) end should "have the url to the \"complex\" post from 2008-11-21" do @@ -645,7 +645,7 @@ CONTENT end should "not cause an error" do - refute_match(/markdown\-html\-error/, @result) + refute_match(%r!markdown\-html\-error!, @result) end should "have the url to the \"yaml_with_dots\" item" do @@ -672,7 +672,7 @@ CONTENT end should "not cause an error" do - refute_match(/markdown\-html\-error/, @result) + refute_match(%r!markdown\-html\-error!, @result) end should "have the url to the \"sanitized_path\" item" do @@ -727,7 +727,7 @@ CONTENT }) end @result ||= "" - refute_match(/SYMLINK TEST/, @result) + refute_match(%r!SYMLINK TEST!, @result) end should "not expose the existence of symlinked files" do @@ -954,15 +954,15 @@ CONTENT end should "include file as variable with liquid filters" do - assert_match(/1 included/, @content) - assert_match(/2 included/, @content) - assert_match(/3 included/, @content) + assert_match(%r!1 included!, @content) + assert_match(%r!2 included!, @content) + assert_match(%r!3 included!, @content) end should "include file as variable and liquid filters with arbitrary whitespace" do - assert_match(/4 included/, @content) - assert_match(/5 included/, @content) - assert_match(/6 included/, @content) + assert_match(%r!4 included!, @content) + assert_match(%r!5 included!, @content) + assert_match(%r!6 included!, @content) end should "include file as variable and filters with additional parameters" do @@ -971,7 +971,7 @@ CONTENT end should "include file as partial variable" do - assert_match(/8 included/, @content) + assert_match(%r!8 included!, @content) end end end @@ -986,15 +986,15 @@ CONTENT end should "include file as variable with liquid filters" do - assert_match(/1 relative_include/, @content) - assert_match(/2 relative_include/, @content) - assert_match(/3 relative_include/, @content) + assert_match(%r!1 relative_include!, @content) + assert_match(%r!2 relative_include!, @content) + assert_match(%r!3 relative_include!, @content) end should "include file as variable and liquid filters with arbitrary whitespace" do - assert_match(/4 relative_include/, @content) - assert_match(/5 relative_include/, @content) - assert_match(/6 relative_include/, @content) + assert_match(%r!4 relative_include!, @content) + assert_match(%r!5 relative_include!, @content) + assert_match(%r!6 relative_include!, @content) end should "include file as variable and filters with additional parameters" do @@ -1003,11 +1003,11 @@ CONTENT end should "include file as partial variable" do - assert_match(/8 relative_include/, @content) + assert_match(%r!8 relative_include!, @content) end should "include files relative to self" do - assert_match(/9 —\ntitle: Test Post Where YAML/, @content) + assert_match(%r!9 —\ntitle: Test Post Where YAML!, @content) end context "trying to do bad stuff" do @@ -1087,7 +1087,7 @@ CONTENT }) end @result ||= "" - refute_match(/SYMLINK TEST/, @result) + refute_match(%r!SYMLINK TEST!, @result) end should "not expose the existence of symlinked files" do