[DRE-commits] [ruby-rspec-instafail] 42/108: Extract rspec 1 & 2 versions to separate files

Hideki Yamane henrich at moszumanska.debian.org
Sun Nov 15 18:36:18 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 8a9308e54ac274e472a80325712cdf38ef93038e
Author: Steve Tooke <steve.tooke at gmail.com>
Date:   Tue Nov 16 22:45:05 2010 +0000

    Extract rspec 1 & 2 versions to separate files
---
 lib/rspec/instafail.rb         | 42 ++----------------------------------------
 lib/rspec/instafail/rspec_1.rb | 25 +++++++++++++++++++++++++
 lib/rspec/instafail/rspec_2.rb | 19 +++++++++++++++++++
 3 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/lib/rspec/instafail.rb b/lib/rspec/instafail.rb
index 8661b29..8a04132 100644
--- a/lib/rspec/instafail.rb
+++ b/lib/rspec/instafail.rb
@@ -2,49 +2,11 @@ module RSpec
   begin
     # rspec 2.x
     require 'rspec/core/formatters/progress_formatter'
-    class Instafail < RSpec::Core::Formatters::ProgressFormatter
-      def example_failed(example)
-        @counter ||= 0
-        @counter += 1
-        exception = example.metadata[:execution_result][:exception_encountered]
-        short_padding = '  '
-        padding = '     '
-        output.puts
-        output.puts "#{short_padding}#{@counter}) #{example.full_description}"
-        output.puts "#{padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
-        output.puts "#{padding}#{red(exception)}"
-        format_backtrace(exception.backtrace, example).each do |backtrace_info|
-          output.puts grey("#{padding}# #{backtrace_info}")
-        end
-        output.flush
-      end
-    end
+    require 'rspec/instafail/rspec_2'
   rescue LoadError => try_rspec_1
     # rspec 1.x
     require 'spec/runner/formatter/progress_bar_formatter'
-    class Instafail < Spec::Runner::Formatter::ProgressBarFormatter
-      def example_failed(example, counter, failure)
-        short_padding = '  '
-        padding = '     '
-
-        output.puts
-        output.puts red("#{short_padding}#{counter}) #{example_group.description} #{example.description}")
-        output.puts "#{padding}#{red(failure.exception)}"
-
-        [*format_backtrace(failure.exception.backtrace)].each do |backtrace_info|
-          output.puts insta_gray("#{padding}# #{backtrace_info.strip}")
-        end
-
-        output.flush
-      end
-
-      private
-
-      # there is a gray() that returns nil, so we use our own...
-      def insta_gray(text)
-        colour(text, "\e[90m")
-      end
-    end
+    require 'rspec/instafail/rspec_1'
   end
 
   Instafail::VERSION = File.read( File.join(File.dirname(__FILE__),'..','..','VERSION') ).strip
diff --git a/lib/rspec/instafail/rspec_1.rb b/lib/rspec/instafail/rspec_1.rb
new file mode 100644
index 0000000..8f2a239
--- /dev/null
+++ b/lib/rspec/instafail/rspec_1.rb
@@ -0,0 +1,25 @@
+module RSpec
+  class Instafail < Spec::Runner::Formatter::ProgressBarFormatter
+    def example_failed(example, counter, failure)
+      short_padding = '  '
+      padding = '     '
+
+      output.puts
+      output.puts red("#{short_padding}#{counter}) #{example_group.description} #{example.description}")
+      output.puts "#{padding}#{red(failure.exception)}"
+
+      [*format_backtrace(failure.exception.backtrace)].each do |backtrace_info|
+        output.puts insta_gray("#{padding}# #{backtrace_info.strip}")
+      end
+
+      output.flush
+    end
+
+    private
+
+    # there is a gray() that returns nil, so we use our own...
+    def insta_gray(text)
+      colour(text, "\e[90m")
+    end
+  end
+end
diff --git a/lib/rspec/instafail/rspec_2.rb b/lib/rspec/instafail/rspec_2.rb
new file mode 100644
index 0000000..e5e0724
--- /dev/null
+++ b/lib/rspec/instafail/rspec_2.rb
@@ -0,0 +1,19 @@
+module RSpec
+  class Instafail < RSpec::Core::Formatters::ProgressFormatter
+    def example_failed(example)
+      @counter ||= 0
+      @counter += 1
+      exception = example.metadata[:execution_result][:exception_encountered]
+      short_padding = '  '
+      padding = '     '
+      output.puts
+      output.puts "#{short_padding}#{@counter}) #{example.full_description}"
+      output.puts "#{padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
+      output.puts "#{padding}#{red(exception)}"
+      format_backtrace(exception.backtrace, example).each do |backtrace_info|
+        output.puts grey("#{padding}# #{backtrace_info}")
+      end
+      output.flush
+    end
+  end
+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