[DRE-commits] [ruby-rspec-instafail] 54/108: Refactor specs a bit in preparation for testing changed error printing

Hideki Yamane henrich at moszumanska.debian.org
Sun Nov 15 18:36:20 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 c5cc4950bb82ca5e1e7daff9182f2b3914dc0f37
Author: Raphael <raphael at joindiaspora.com>
Date:   Thu Dec 16 11:27:37 2010 -0800

    Refactor specs a bit in preparation for testing changed error printing
---
 spec/instafail_spec.rb | 38 +++++++++++++++++++++++---------------
 spec/rspec_2/a_test.rb | 10 +++++++---
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/spec/instafail_spec.rb b/spec/instafail_spec.rb
index bf5cfe4..9d55351 100644
--- a/spec/instafail_spec.rb
+++ b/spec/instafail_spec.rb
@@ -23,37 +23,44 @@ EXP
     output.should =~ Regexp.new(expected_output, 'x')
   end
 
-  it "works correctly with RSpec 2.x (but backtrace might be broken)" do
-    output = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
-    expected = <<EXP
-  1\\) x a
+  context 'Rspec 2.x' do
+    before(:all)do
+      @rspec_result = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
+    end
+    before do
+      @output = @rspec_result.dup
+    end
+    it "outputs logical failures" do
+      expected = <<EXP
+  1\\) x fails logically
      Failure\\/Error: 1\\.should == 2
      expected: 2,
      got: 1 \\(using ==\\)
 EXP
-    output.should =~ Regexp.new(expected, 'x')
+      @output.should =~ Regexp.new(expected, 'x')
 
-    output.should include('/a_test.rb:5')
+      @output.should include('/a_test.rb:5')
+    end
+    it 'outputs the remaining passing specs and the ending block' do
 
-    expected = <<EXP
+      expected = <<EXP
 \\.\\.\\*\\.
 
 Pending:
-  x d
+  x pends
     # No reason given
     # \\./a_test\\.rb:14
 
 Finished in \\d\\.\\d+ seconds
 5 examples, 1 failure, 1 pending
 EXP
-    output.should =~ Regexp.new(expected, 'x')
+      @output.should =~ Regexp.new(expected, 'x')
 
-  end
+    end
 
-  it "works correctly with RSpec 2.x" do
-    pending 'the backtrace for the error is always absolute on my machine'
-    output = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
-    expected_output = <<EXP
+    it "works correctly with RSpec 2.x" do
+      pending 'the backtrace for the error is always absolute on my machine'
+      expected_output = <<EXP
   1\\) x a
      Failure\\/Error: 1\\.should == 2
      expected: 2,
@@ -70,8 +77,9 @@ Finished in \\d\\.\\d+ seconds
 5 examples, 1 failure, 1 pending
 EXP
 
-    output.should =~ Regexp.new(expected_output, 'x')
+      @output.should =~ Regexp.new(expected_output, 'x')
 
+    end
   end
 end
 
diff --git a/spec/rspec_2/a_test.rb b/spec/rspec_2/a_test.rb
index 5fc5d1f..04a0934 100644
--- a/spec/rspec_2/a_test.rb
+++ b/spec/rspec_2/a_test.rb
@@ -1,7 +1,7 @@
 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rspec', 'instafail'))
 
 describe 'x' do
-  it 'a' do
+  it 'fails logically' do
     1.should == 2
   end
 
@@ -11,11 +11,15 @@ describe 'x' do
   it 'c' do
   end
 
-  it 'd' do
+  it 'pends' do
     pending
     raise
   end
 
   it 'e' do
   end
-end
\ No newline at end of file
+end
+
+class ExceptionWrappingException < RuntimeError
+  attr_accessor :original_exception
+end

-- 
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