[DRE-commits] [ruby-rspec-instafail] 03/126: add specs and fix fir rspec2

Hideki Yamane henrich at moszumanska.debian.org
Sun Nov 15 19:14:56 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 3d5dbb30667b87708aa8fa5e9b7394fbb97403fe
Author: grosser <grosser.michael at gmail.com>
Date:   Sun Aug 15 17:10:48 2010 +0200

    add specs and fix fir rspec2
---
 Rakefile                  |  3 +++
 lib/rspec/instafail.rb    | 33 ++++++++++++++++++++-------------
 spec/instafail_spec.rb    | 13 +++++++++++++
 spec/rspec_1/Gemfile      |  2 ++
 spec/rspec_1/Gemfile.lock | 10 ++++++++++
 spec/rspec_1/a_test.rb    | 21 +++++++++++++++++++++
 spec/rspec_2/Gemfile      |  2 ++
 spec/rspec_2/Gemfile.lock | 18 ++++++++++++++++++
 spec/rspec_2/a_test.rb    | 21 +++++++++++++++++++++
 9 files changed, 110 insertions(+), 13 deletions(-)

diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..8d33439
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,3 @@
+task :default => :spec
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color --backtrace']}
\ No newline at end of file
diff --git a/lib/rspec/instafail.rb b/lib/rspec/instafail.rb
index aa8412c..d3ce366 100644
--- a/lib/rspec/instafail.rb
+++ b/lib/rspec/instafail.rb
@@ -1,21 +1,28 @@
 module RSpec
-  klass = if defined? Spec
+  if defined? Spec
     # rspec 1.x
     require 'spec/runner/formatter/progress_bar_formatter'
-    Spec::Runner::Formatter::ProgressBarFormatter
+    class Instafail < Spec::Runner::Formatter::ProgressBarFormatter
+      def example_failed(example, counter, failure)
+        output.puts
+        output.puts red("#{counter}: #{example_group.description} #{example.description}")
+        output.puts " -> #{failure.exception}"
+        output.flush
+      end
+    end
   else
     # rspec 2.x
-    require 'rspec/core/formatter/progress_formatter'
-    RSpec::Core::Formatters::ProgressFormatter
-  end
-
-  klass = Class.new(klass)
-  klass.class_eval do
-    def example_failed(example, counter, failure)
-      output.puts
-      output.puts red("#{counter}: #{example_group.description} #{example.description}")
-      output.puts " -> #{failure.exception}"
-      output.flush
+    require 'rspec'
+    require 'rspec/core/formatters/progress_formatter'
+    class Instafail < RSpec::Core::Formatters::ProgressFormatter
+      def example_failed(example)
+        @counter ||= 0
+        @counter += 1
+        output.puts
+        output.puts red("#{@counter}: #{example.example_group.description} #{example.description}")
+        output.puts " -> #{example.metadata[:execution_result][:exception_encountered]}"
+        output.flush
+      end
     end
   end
 end
\ No newline at end of file
diff --git a/spec/instafail_spec.rb b/spec/instafail_spec.rb
new file mode 100644
index 0000000..5e73d0d
--- /dev/null
+++ b/spec/instafail_spec.rb
@@ -0,0 +1,13 @@
+describe 'RSpec::Instafail' do
+  it "works correctly with RSpec 1.x" do
+    output = `cd spec/rspec_1 && bundle exec spec a_test.rb --format RSpec::Instafail`
+    output.should include("1: x a\n -> expected: 2,\n     got: 1 (using ==)\n\.\.\*\.")
+    output.should =~ /Finished in \d\.\d+ seconds/
+  end
+
+  it "works correctly with RSpec 2.x" do
+    output = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
+    output.should =~ /1: x a\n -> expected: 2,\n     got: 1 .*\.\.\*\./m
+    output.should =~ /Finished in \d\.\d+ seconds/
+  end
+end
\ No newline at end of file
diff --git a/spec/rspec_1/Gemfile b/spec/rspec_1/Gemfile
new file mode 100644
index 0000000..9d42535
--- /dev/null
+++ b/spec/rspec_1/Gemfile
@@ -0,0 +1,2 @@
+source 'http://rubygems.org'
+gem 'rspec', '1.3.0'
\ No newline at end of file
diff --git a/spec/rspec_1/Gemfile.lock b/spec/rspec_1/Gemfile.lock
new file mode 100644
index 0000000..a0bcbcb
--- /dev/null
+++ b/spec/rspec_1/Gemfile.lock
@@ -0,0 +1,10 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    rspec (1.3.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  rspec (= 1.3.0)
diff --git a/spec/rspec_1/a_test.rb b/spec/rspec_1/a_test.rb
new file mode 100644
index 0000000..5fc5d1f
--- /dev/null
+++ b/spec/rspec_1/a_test.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rspec', 'instafail'))
+
+describe 'x' do
+  it 'a' do
+    1.should == 2
+  end
+
+  it 'b' do
+  end
+
+  it 'c' do
+  end
+
+  it 'd' do
+    pending
+    raise
+  end
+
+  it 'e' do
+  end
+end
\ No newline at end of file
diff --git a/spec/rspec_2/Gemfile b/spec/rspec_2/Gemfile
new file mode 100644
index 0000000..3240c99
--- /dev/null
+++ b/spec/rspec_2/Gemfile
@@ -0,0 +1,2 @@
+source 'http://rubygems.org'
+gem 'rspec', '2.0.0.beta.19'
\ No newline at end of file
diff --git a/spec/rspec_2/Gemfile.lock b/spec/rspec_2/Gemfile.lock
new file mode 100644
index 0000000..1e4c87e
--- /dev/null
+++ b/spec/rspec_2/Gemfile.lock
@@ -0,0 +1,18 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    diff-lcs (1.1.2)
+    rspec (2.0.0.beta.19)
+      rspec-core (= 2.0.0.beta.19)
+      rspec-expectations (= 2.0.0.beta.19)
+      rspec-mocks (= 2.0.0.beta.19)
+    rspec-core (2.0.0.beta.19)
+    rspec-expectations (2.0.0.beta.19)
+      diff-lcs (>= 1.1.2)
+    rspec-mocks (2.0.0.beta.19)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  rspec (= 2.0.0.beta.19)
diff --git a/spec/rspec_2/a_test.rb b/spec/rspec_2/a_test.rb
new file mode 100644
index 0000000..5fc5d1f
--- /dev/null
+++ b/spec/rspec_2/a_test.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rspec', 'instafail'))
+
+describe 'x' do
+  it 'a' do
+    1.should == 2
+  end
+
+  it 'b' do
+  end
+
+  it 'c' do
+  end
+
+  it 'd' do
+    pending
+    raise
+  end
+
+  it 'e' do
+  end
+end
\ No newline at end of file

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