[DRE-commits] [ruby-rspec] 02/14: more escaping in tests
Cédric Boutillier
boutil at moszumanska.debian.org
Wed Apr 1 23:29:51 UTC 2015
This is an automated email from the git hooks/post-receive script.
boutil pushed a commit to branch master
in repository ruby-rspec.
commit 16f514b3a05ec181fe9e52d8814f442a390d4b93
Author: Cédric Boutillier <boutil at debian.org>
Date: Wed Apr 1 09:51:57 2015 +0200
more escaping in tests
---
debian/patches/escape-path-in-match.patch | 188 ++++++++++++++++++++++++++++++
1 file changed, 188 insertions(+)
diff --git a/debian/patches/escape-path-in-match.patch b/debian/patches/escape-path-in-match.patch
index d1ba5bf..094f57a 100644
--- a/debian/patches/escape-path-in-match.patch
+++ b/debian/patches/escape-path-in-match.patch
@@ -40,3 +40,191 @@
expect(Kernel).to receive(:warn).with(expected_warning)
expect(nil).to receive(:foo)
+--- a/rspec-support/spec/rspec/support/warnings_spec.rb
++++ b/rspec-support/spec/rspec/support/warnings_spec.rb
+@@ -41,7 +41,7 @@
+ end
+
+ it 'sets the calling line' do
+- expect(::Kernel).to receive(:warn).with(/#{__FILE__}:#{__LINE__+1}/)
++ expect(::Kernel).to receive(:warn).with(/#{Regexp.escape(__FILE__)}:#{__LINE__+1}/)
+ warning_object.send(helper, 'Message')
+ end
+
+##--- a/rspec-support/lib/rspec/support/spec/shell_out.rb
+##+++ b/rspec-support/lib/rspec/support/spec/shell_out.rb
+##@@ -39,7 +39,7 @@
+## def run_ruby_with_current_load_path(ruby_command, *flags)
+## command = [
+## FileUtils::RUBY,
+##- "-I#{$LOAD_PATH.map(&:shellescape).join(File::PATH_SEPARATOR)}",
+##+ "-I#{$LOAD_PATH.join(File::PATH_SEPARATOR)}",
+## "-e", ruby_command, *flags
+## ]
+##
+--- a/rspec-core/spec/rspec/core/rake_task_spec.rb
++++ b/rspec-core/spec/rspec/core/rake_task_spec.rb
+@@ -36,7 +36,7 @@
+
+ context "default" do
+ it "renders rspec" do
+- expect(spec_command).to match(/^#{ruby} #{default_load_path_opts} '?#{task.rspec_path}'?/)
++ expect(spec_command).to match(/^#{ruby} #{default_load_path_opts} '?#{Regexp.escape(task.rspec_path.shellescape)}'?/)
+ end
+ end
+
+@@ -50,14 +50,14 @@
+ context "with ruby options" do
+ it "renders them before the rspec path" do
+ task.ruby_opts = "-w"
+- expect(spec_command).to match(/^#{ruby} -w #{default_load_path_opts} '?#{task.rspec_path}'?/)
++ expect(spec_command).to match(/^#{ruby} -w #{default_load_path_opts} '?#{Regexp.escape(task.rspec_path.shellescape)}'?/)
+ end
+ end
+
+ context "with rspec_opts" do
+ it "adds the rspec_opts" do
+ task.rspec_opts = "-Ifoo"
+- expect(spec_command).to match(/#{task.rspec_path}.*-Ifoo/)
++ expect(spec_command).to match(/#{Regexp.escape(task.rspec_path.shellescape)}.*-Ifoo/)
+ end
+ end
+
+--- a/rspec-core/spec/rspec/core/example_spec.rb
++++ b/rspec-core/spec/rspec/core/example_spec.rb
+@@ -66,7 +66,7 @@
+ RSpec.configuration.format_docstrings { |s| s.upcase }
+ example_group.example { }
+ example_group.run
+- pattern = /EXAMPLE AT #{relative_path(__FILE__).upcase}:#{__LINE__ - 2}/
++ pattern = /EXAMPLE AT #{Regexp.escape(relative_path(__FILE__).upcase)}:#{__LINE__ - 2}/
+ expect(example_group.examples.first.description).to match(pattern)
+ end
+ end
+@@ -89,14 +89,14 @@
+ it "uses the file and line number if there is no matcher-generated description" do
+ example = example_group.example {}
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 2}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 2}/)
+ end
+
+ it "uses the file and line number if there is an error before the matcher" do
+ example = example_group.example { expect(5).to eq(5) }
+ example_group.before { raise }
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 3}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 3}/)
+ end
+
+ context "if the example is pending" do
+@@ -109,7 +109,7 @@
+ it "uses the file and line number of the example if no matcher ran" do
+ example = example_group.example { pending; fail }
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 2}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 2}/)
+ end
+ end
+
+@@ -175,14 +175,14 @@
+ it "uses the file and line number if there is no matcher-generated description" do
+ example = example_group.example {}
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 2}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 2}/)
+ end
+
+ it "uses the file and line number if there is an error before the matcher" do
+ example = example_group.example { expect(5).to eq(5) }
+ example_group.before { raise }
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 3}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 3}/)
+ end
+ end
+
+@@ -198,7 +198,7 @@
+ it "uses the file and line number" do
+ example = example_group.example { assert 5 == 5 }
+ example_group.run
+- expect(example.description).to match(/example at #{relative_path(__FILE__)}:#{__LINE__ - 2}/)
++ expect(example.description).to match(/example at #{Regexp.escape(relative_path(__FILE__))}:#{__LINE__ - 2}/)
+ end
+ end
+ end
+--- a/rspec-core/spec/rspec/core/configuration_spec.rb
++++ b/rspec-core/spec/rspec/core/configuration_spec.rb
+@@ -37,7 +37,7 @@
+
+ it 'prints a notice indicating the reconfigured output_stream will be ignored' do
+ config.deprecation_stream = double("IO")
+- expect(config).to have_received(:warn).with(/deprecation_stream.*#{__FILE__}:#{__LINE__ - 1}/)
++ expect(config).to have_received(:warn).with(/deprecation_stream.*#{Regexp.escape(__FILE__)}:#{__LINE__ - 1}/)
+ end
+
+ it 'does not change the value of `deprecation_stream`' do
+@@ -72,7 +72,7 @@
+
+ it 'prints a notice indicating the reconfigured output_stream will be ignored' do
+ config.output_stream = StringIO.new
+- expect(config).to have_received(:warn).with(/output_stream.*#{__FILE__}:#{__LINE__ - 1}/)
++ expect(config).to have_received(:warn).with(/output_stream.*#{Regexp.escape(__FILE__)}:#{__LINE__ - 1}/)
+ end
+
+ it 'does not change the value of `output_stream`' do
+--- a/rspec-core/lib/rspec/core/metadata.rb
++++ b/rspec-core/lib/rspec/core/metadata.rb
+@@ -34,7 +34,7 @@
+ # http://rubular.com/r/duOrD4i3wb
+ # http://rubular.com/r/sbAMHFrOx1
+ def self.relative_path_regex
+- @relative_path_regex ||= /(\A|\s)#{File.expand_path('.')}(#{File::SEPARATOR}|\s|\Z)/
++ @relative_path_regex ||= /(\A|\s)#{Regexp.escape(File.expand_path('.'))}(#{File::SEPARATOR}|\s|\Z)/
+ end
+
+ # @api private
+--- a/rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
++++ b/rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
+@@ -50,7 +50,7 @@
+ def expect_warning_with_call_site(file, line, expected=//)
+ expect(::Kernel).to receive(:warn) do |message|
+ expect(message).to match expected
+- expect(message).to match(/Called from #{file}:#{line}/)
++ expect(message).to match(/Called from #{Regexp.escape(file)}:#{line}/)
+ end
+ end
+
+--- a/rspec-mocks/spec/rspec/mocks/and_call_original_spec.rb
++++ b/rspec-mocks/spec/rspec/mocks/and_call_original_spec.rb
+@@ -68,7 +68,7 @@
+ end
+
+ it 'warns when you override an existing implementation' do
+- expect(RSpec).to receive(:warning).with(/overriding a previous stub implementation of `meth_1`.*#{__FILE__}:#{__LINE__ + 1}/)
++ expect(RSpec).to receive(:warning).with(/overriding a previous stub implementation of `meth_1`.*#{Regexp.escape(__FILE__)}:#{__LINE__ + 1}/)
+ expect(instance).to receive(:meth_1) { true }.and_call_original
+ instance.meth_1
+ end
+--- a/rspec-mocks/spec/rspec/mocks/matchers/receive_messages_spec.rb
++++ b/rspec-mocks/spec/rspec/mocks/matchers/receive_messages_spec.rb
+@@ -92,7 +92,7 @@
+
+ it 'fails with the correct location' do
+ expect(obj).to receive_messages(:a => 1, :b => 2); line = __LINE__
+- expect(expectation_error.backtrace[0]).to match(/#{__FILE__}:#{line}/)
++ expect(expectation_error.backtrace[0]).to match(/#{Regexp.escape(__FILE__)}:#{line}/)
+ end
+
+ it_behaves_like "complains when given blocks"
+--- a/rspec-mocks/spec/rspec/mocks/combining_implementation_instructions_spec.rb
++++ b/rspec-mocks/spec/rspec/mocks/combining_implementation_instructions_spec.rb
+@@ -158,7 +158,7 @@
+ end
+
+ it 'warns when the inner implementation block is overriden' do
+- expect(RSpec).to receive(:warning).with(/overriding a previous stub implementation of `foo`.*#{__FILE__}:#{__LINE__ + 1}/)
++ expect(RSpec).to receive(:warning).with(/overriding a previous stub implementation of `foo`.*#{Regexp.escape(__FILE__)}:#{__LINE__ + 1}/)
+ allow(double).to receive(:foo).with(:arg) { :with_block }.at_least(:once) { :at_least_block }
+ end
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-rspec.git
More information about the Pkg-ruby-extras-commits
mailing list