diff --git a/features/step_definitions/cucumber_rails_steps.rb b/features/step_definitions/cucumber_rails_steps.rb index dc4f49a7..79403c15 100644 --- a/features/step_definitions/cucumber_rails_steps.rb +++ b/features/step_definitions/cucumber_rails_steps.rb @@ -26,7 +26,7 @@ new_content = [] content.each do |line| - next if line =~ /gem ["|']#{gem_name}["|'].*/ + next if /gem ["|']#{gem_name}["|'].*/.match?(line) new_content << line end diff --git a/features/support/cucumber_rails_helper.rb b/features/support/cucumber_rails_helper.rb index f05042f6..a1a75f27 100644 --- a/features/support/cucumber_rails_helper.rb +++ b/features/support/cucumber_rails_helper.rb @@ -25,7 +25,7 @@ def add_gem(name, *args) gem_regexp = /gem ["']#{name}["'].*$/ gemfile_content = File.read(expand_path('Gemfile')) - if gemfile_content =~ gem_regexp + if gemfile_content&.match?(gem_regexp) updated_gemfile_content = gemfile_content.gsub(gem_regexp, line) overwrite_file('Gemfile', updated_gemfile_content) else