[DRE-commits] [ruby-rspec-instafail] 84/126: Imported Upstream version 0.2.4
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 0a08b0e31de2670c7f0c65145f88d7d298dee628
Author: Hideki Yamane <henrich at debian.org>
Date: Thu Jan 3 13:25:38 2013 +0900
Imported Upstream version 0.2.4
---
Rakefile | 25 ++++++++++++++++++
Readme.md | 52 +++++++++++++++++++++++++++++++++++++
lib/rspec/instafail.rb | 14 ++++++++++
lib/rspec/instafail/rspec_1.rb | 9 +++++++
lib/rspec/instafail/rspec_2.rb | 37 ++++++++++++++++++++++++++
lib/rspec/instafail/version.rb | 2 ++
metadata.yml | 59 ++++++++++++++++++++++++++++++++++++++++++
rspec-instafail.gemspec | 12 +++++++++
spec/instafail_spec.rb | 51 ++++++++++++++++++++++++++++++++++++
spec/rspec_1/Gemfile | 2 ++
spec/rspec_1/Gemfile.lock | 10 +++++++
spec/rspec_1/a_test.rb | 35 +++++++++++++++++++++++++
spec/rspec_2/Gemfile | 2 ++
spec/rspec_2/Gemfile.lock | 18 +++++++++++++
spec/rspec_2/a_test.rb | 48 ++++++++++++++++++++++++++++++++++
15 files changed, 376 insertions(+)
diff --git a/Rakefile b/Rakefile
new file mode 100755
index 0000000..f321e31
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,25 @@
+require "bundler"
+Bundler::GemHelper.install_tasks
+
+task :default do
+ sh "cd spec/rspec_1 && (bundle || bundle install) > /dev/null"
+ sh "cd spec/rspec_2 && (bundle || bundle install) > /dev/null"
+ sh "rspec spec/"
+end
+
+rule /^version:bump:.*/ do |t|
+ file = 'lib/rspec/instafail/version.rb'
+
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
+
+ version_file = File.read(file)
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
+ version_parts[index] = version_parts[index].to_i + 1
+ version_parts[2] = 0 if index < 2
+ version_parts[1] = 0 if index < 1
+ new_version = version_parts * '.'
+ File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
+
+ sh "git add #{file} && git commit -m 'bump version to #{new_version}'"
+end
diff --git a/Readme.md b/Readme.md
new file mode 100755
index 0000000..179d34d
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,52 @@
+Show failing specs instantly. Show passing spec as green dots as usual.
+
+Output
+======
+ ....................................................*....
+ 1) ApplicationController#sign_out_and_redirect with JSON should return JSON indicating success
+ Failure/Error: json_response = JSON.parse response.body
+ A JSON text must at least contain two octets!
+ # /Users/miwillhite/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:146:in `initialize'
+ # /Users/miwillhite/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:146:in `new'
+ # /Users/miwillhite/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:146:in `parse'
+ # ./spec/controllers/application_controller_spec.rb:17:in `block (4 levels) in <top (required)>'
+ ..................................................................
+
+ Finished in 650.095614 seconds
+
+ 1680 examples, 1 failure, 1 pending
+
+
+
+Install
+=======
+As Gem:
+ gem install rspec-instafail
+
+ # spec/spec.opts (.rspec for rspec 2)
+ --require rspec/instafail
+ --format RSpec::Instafail
+
+As plugin:
+ rails plugin install git://github.com/grosser/rspec-instafail.git
+
+ # spec/spec.opts (.rspec for rspec 2)
+ --require vendor/plugins/rspec-instafail/lib/rspec/instafail
+ --format RSpec::Instafail
+
+Authors
+=======
+
+### [Contributors](http://github.com/grosser/rspec-instafail/contributors)
+ - [Matthew Willhite](http://github.com/miwillhite)
+ - [Jeff Kreeftmeijer](http://jeffkreeftmeijer.com)
+ - [Steve Tooke](http://tooky.github.com)
+ - [Josh Ellithorpe](https://github.com/zquestz)
+ - [Raphael Sofaer](https://github.com/rsofaer)
+ - [Mike Mazur](https://github.com/mikem)
+ - [vernonR2](https://github.com/vernonR2)
+ - [Olek Janiszewski](https://github.com/exviva)
+
+[Michael Grosser](http://grosser.it)<br/>
+michael at grosser.it<br/>
+License: MIT
diff --git a/lib/rspec/instafail.rb b/lib/rspec/instafail.rb
new file mode 100755
index 0000000..68fba41
--- /dev/null
+++ b/lib/rspec/instafail.rb
@@ -0,0 +1,14 @@
+module RSpec
+ # Rails 3: when installed as plugin, lib is not in load-path when running tests
+ # https://github.com/grosser/rspec-instafail/pull/3
+ lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
+ $LOAD_PATH << lib unless $LOAD_PATH.include?(lib)
+
+ begin
+ require "rspec/instafail/rspec_2"
+ rescue LoadError # try rspec 1
+ require "rspec/instafail/rspec_1"
+ end
+
+ require 'rspec/instafail/version'
+end
diff --git a/lib/rspec/instafail/rspec_1.rb b/lib/rspec/instafail/rspec_1.rb
new file mode 100755
index 0000000..c79eef3
--- /dev/null
+++ b/lib/rspec/instafail/rspec_1.rb
@@ -0,0 +1,9 @@
+require 'spec/runner/formatter/progress_bar_formatter'
+
+module RSpec
+ class Instafail < Spec::Runner::Formatter::ProgressBarFormatter
+ def example_failed(example, counter, failure)
+ dump_failure(counter, failure)
+ end
+ end
+end
diff --git a/lib/rspec/instafail/rspec_2.rb b/lib/rspec/instafail/rspec_2.rb
new file mode 100755
index 0000000..bf3405a
--- /dev/null
+++ b/lib/rspec/instafail/rspec_2.rb
@@ -0,0 +1,37 @@
+require 'rspec/core/formatters/progress_formatter'
+
+module RSpec
+ class Instafail < RSpec::Core::Formatters::ProgressFormatter
+ def example_failed(example)
+ # do what BaseFormatter#example_failed would do
+ @failed_examples << example
+
+ # do what BaseTextFormatter#dump_failures would do
+ index = failed_examples.size - 1
+ _dump_pending_example(example, index)
+ 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
+ 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/lib/rspec/instafail/version.rb b/lib/rspec/instafail/version.rb
new file mode 100755
index 0000000..9885290
--- /dev/null
+++ b/lib/rspec/instafail/version.rb
@@ -0,0 +1,2 @@
+require 'rspec/instafail'
+RSpec::Instafail::VERSION = '0.2.4'
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..0dcb2b1
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,59 @@
+--- !ruby/object:Gem::Specification
+name: rspec-instafail
+version: !ruby/object:Gem::Version
+ version: 0.2.4
+ prerelease:
+platform: ruby
+authors:
+- Michael Grosser
+autorequire:
+bindir: bin
+cert_chain: []
+date: 2012-03-27 00:00:00.000000000 Z
+dependencies: []
+description:
+email: michael at grosser.it
+executables: []
+extensions: []
+extra_rdoc_files: []
+files:
+- Rakefile
+- Readme.md
+- lib/rspec/instafail.rb
+- lib/rspec/instafail/rspec_1.rb
+- lib/rspec/instafail/rspec_2.rb
+- lib/rspec/instafail/version.rb
+- rspec-instafail.gemspec
+- spec/instafail_spec.rb
+- spec/rspec_1/Gemfile
+- spec/rspec_1/Gemfile.lock
+- spec/rspec_1/a_test.rb
+- spec/rspec_2/Gemfile
+- spec/rspec_2/Gemfile.lock
+- spec/rspec_2/a_test.rb
+homepage: http://github.com/grosser/rspec-instafail
+licenses:
+- MIT
+post_install_message:
+rdoc_options: []
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ! '>='
+ - !ruby/object:Gem::Version
+ version: '0'
+required_rubygems_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ! '>='
+ - !ruby/object:Gem::Version
+ version: '0'
+requirements: []
+rubyforge_project:
+rubygems_version: 1.8.15
+signing_key:
+specification_version: 3
+summary: Show failing specs instantly
+test_files: []
diff --git a/rspec-instafail.gemspec b/rspec-instafail.gemspec
new file mode 100755
index 0000000..d02b261
--- /dev/null
+++ b/rspec-instafail.gemspec
@@ -0,0 +1,12 @@
+$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
+name = 'rspec-instafail'
+require "rspec/instafail/version"
+
+Gem::Specification.new name, RSpec::Instafail::VERSION do |s|
+ s.summary = "Show failing specs instantly"
+ s.authors = ["Michael Grosser"]
+ s.email = "michael at grosser.it"
+ s.homepage = "http://github.com/grosser/#{name}"
+ s.files = `git ls-files`.split("\n")
+ s.license = "MIT"
+end
diff --git a/spec/instafail_spec.rb b/spec/instafail_spec.rb
new file mode 100755
index 0000000..bd3c7d9
--- /dev/null
+++ b/spec/instafail_spec.rb
@@ -0,0 +1,51 @@
+describe 'RSpec::Instafail' do
+ context "RSpec 1.x" do
+ before :all do
+ @rspec_result = `cd spec/rspec_1 && bundle exec spec a_test.rb --format RSpec::Instafail`
+ end
+
+ before do
+ @output = @rspec_result.dup
+ end
+
+ it "outputs failures at start of output" do
+ @output.should =~ /^\s*1\)\s*'x fails logically'/m
+ end
+
+ it 'outputs errors in middle of output' do
+ @output.should =~ /\.\.\*\s*2\)\s*RuntimeError in 'x raises a simple error'/m
+ end
+
+ it 'outputs the the ending block' do
+ @output.should =~ /Finished in \d\.\d+ seconds\s*7 examples, 3 failures, 1 pending/
+ end
+ end
+
+ 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 failures at start of output" do
+ @output.should =~ /^\s+1\) x fails logically/m
+ end
+
+ it 'outputs errors in middle of output' do
+ @output.should =~ /\.\.\*\s*2\) x raises a simple error/m
+ end
+
+ it 'outputs the the ending block' do
+ @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_1/Gemfile b/spec/rspec_1/Gemfile
new file mode 100755
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 100755
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 100755
index 0000000..5b0990d
--- /dev/null
+++ b/spec/rspec_1/a_test.rb
@@ -0,0 +1,35 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rspec', 'instafail'))
+
+describe 'x' do
+ it 'fails logically' do
+ 1.should == 2
+ end
+
+ it 'b' do
+ end
+
+ it 'c' do
+ end
+
+ it 'pends' do
+ pending
+ raise
+ end
+
+ it 'raises a simple error' do
+ raise 'shallow failure'
+ end
+
+ it 'raises a hidden error' do
+ error = ExceptionWrappingException.new('There is an error in this error.')
+ error.original_exception = RuntimeError.new('There is no error in this error.')
+ raise error
+ end
+
+ it 'e' do
+ end
+end
+
+class ExceptionWrappingException < RuntimeError
+ attr_accessor :original_exception
+end
diff --git a/spec/rspec_2/Gemfile b/spec/rspec_2/Gemfile
new file mode 100755
index 0000000..9edf720
--- /dev/null
+++ b/spec/rspec_2/Gemfile
@@ -0,0 +1,2 @@
+source 'http://rubygems.org'
+gem 'rspec', '>=2.2'
diff --git a/spec/rspec_2/Gemfile.lock b/spec/rspec_2/Gemfile.lock
new file mode 100755
index 0000000..b68cba3
--- /dev/null
+++ b/spec/rspec_2/Gemfile.lock
@@ -0,0 +1,18 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.3)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rspec (>= 2.2)
diff --git a/spec/rspec_2/a_test.rb b/spec/rspec_2/a_test.rb
new file mode 100755
index 0000000..7228334
--- /dev/null
+++ b/spec/rspec_2/a_test.rb
@@ -0,0 +1,48 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rspec', 'instafail'))
+
+describe 'x' do
+ it 'fails logically' do
+ 1.should == 2
+ end
+
+ it 'b' do
+ end
+
+ it 'c' do
+ end
+
+ it 'pends' do
+ pending
+ raise
+ end
+
+ it 'raises a simple error' do
+ raise 'shallow failure'
+ end
+
+ it 'raises a hidden error' do
+ error = ExceptionWrappingException.new('There is an error in this error.')
+ error.original_exception = RuntimeError.new('There is no error in this error.')
+ raise error
+ end
+
+ 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
+ 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