[DRE-commits] [ruby-rspec-instafail] 79/126: Prevent ancestor modification when dumping errors -- Rspec2 bug
Hideki Yamane
henrich at moszumanska.debian.org
Sun Nov 15 19:15:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository ruby-rspec-instafail.
commit 475cde02f86eaff6c1ad1430cdd6aa0c8f2a031e
Author: grosser <grosser.michael at gmail.com>
Date: Fri Mar 23 21:19:51 2012 -0700
Prevent ancestor modification when dumping errors -- Rspec2 bug
---
lib/rspec/instafail/rspec_2.rb | 12 +++++++++++-
spec/instafail_spec.rb | 7 ++++++-
spec/rspec_2/a_test.rb | 13 +++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/lib/rspec/instafail/rspec_2.rb b/lib/rspec/instafail/rspec_2.rb
index 70de874..bf3405a 100644
--- a/lib/rspec/instafail/rspec_2.rb
+++ b/lib/rspec/instafail/rspec_2.rb
@@ -12,16 +12,26 @@ module RSpec
dump_backtrace(example)
end
+ private
+
def _dump_pending_example(example, index)
if defined? pending_fixed? # > 2.8
if pending_fixed?(example)
dump_pending_fixed(example, index)
else
- dump_failure(example, index)
+ preserve_size(example.example_group.ancestors) do
+ dump_failure(example, index)
+ end
end
else
dump_pending_example_fixed(example, index) || dump_failure(example, index)
end
end
+
+ def preserve_size(array)
+ old = array.size
+ yield
+ array.pop if array.size > old
+ end
end
end
diff --git a/spec/instafail_spec.rb b/spec/instafail_spec.rb
index ad48057..bd3c7d9 100644
--- a/spec/instafail_spec.rb
+++ b/spec/instafail_spec.rb
@@ -39,7 +39,12 @@ describe 'RSpec::Instafail' do
end
it 'outputs the the ending block' do
- @output.should =~ /Finished in \d\.\d+ seconds\s*7 examples, 3 failures, 1 pending/
+ @output.should =~ /Finished in \d\.\d+ seconds\s*9 examples, 4 failures, 1 pending/
+ end
+
+ it "does not add ancestors after failures" do
+ @output.should include('ANCESTORS:2')
+ @output.should_not include('ANCESTORS:3')
end
end
end
diff --git a/spec/rspec_2/a_test.rb b/spec/rspec_2/a_test.rb
index 5b0990d..7228334 100644
--- a/spec/rspec_2/a_test.rb
+++ b/spec/rspec_2/a_test.rb
@@ -28,6 +28,19 @@ describe 'x' do
it 'e' do
end
+
+ context "ancestors" do
+ after do
+ puts "ANCESTORS:#{example.example_group.ancestors.size}"
+ end
+
+ it "does not add ancestors on failure" do
+ raise "BAM"
+ end
+
+ it "does not add ancestors on failure" do
+ end
+ end
end
class ExceptionWrappingException < RuntimeError
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-rspec-instafail.git
More information about the Pkg-ruby-extras-commits
mailing list