Permalink
Browse files

added failure message to output, added examples

  • Loading branch information...
1 parent d73911b commit 74935299c31801dbbee6ef47ab98d349a4052d39 @banister committed Feb 8, 2012
Showing with 115 additions and 29 deletions.
  1. +22 −2 Rakefile
  2. +15 −0 examples/example_bacon.rb
  3. +17 −0 examples/example_minitest.rb
  4. +15 −0 examples/example_rspec.rb
  5. +33 −18 lib/plymouth.rb
  6. +1 −1 lib/plymouth/version.rb
  7. +12 −8 plymouth.gemspec
View
@@ -1,5 +1,8 @@
$:.unshift 'lib'
+dlext = Config::CONFIG['DLEXT']
+direc = File.dirname(__FILE__)
+
PROJECT_NAME = "plymouth"
require "#{PROJECT_NAME}/version"
@@ -16,17 +19,19 @@ CLEAN.include("ext/**/*.log", "ext/**/*.o",
def apply_spec_defaults(s)
s.name = PROJECT_NAME
- s.summary = "FIX ME"
+ s.summary = "Start an interactive session when a test fails"
s.version = CLASS_NAME::VERSION
s.date = Time.now.strftime '%Y-%m-%d'
s.author = "John Mair (banisterfiend)"
s.email = 'jrmair@gmail.com'
s.description = s.summary
s.require_path = 'lib'
- s.add_development_dependency("bacon","~>1.1.0")
s.homepage = "http://github.com/banister/#{PROJECT_NAME}"
s.has_rdoc = 'yard'
s.add_dependency('pry-exception_explorer')
+ s.add_development_dependency("bacon","~>1.1.0")
+ s.add_development_dependency('rspec')
+ s.required_ruby_version = '>= 1.9.2'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
end
@@ -36,6 +41,21 @@ task :test do
sh "bacon -Itest -rubygems test.rb -q"
end
+desc "Run bacon example"
+task :example_bacon do
+ sh "bacon -I#{direc}/lib/ #{direc}/examples/example_bacon.rb "
+end
+
+desc "Run rspec example"
+task :example_rspec do
+ sh "rspec -I#{direc}/lib/ #{direc}/examples/example_rspec.rb "
+end
+
+desc "Run minitest example"
+task :example_minitest do
+ sh "ruby -I#{direc}/lib/ #{direc}/examples/example_minitest.rb "
+end
+
desc "generate gemspec"
task :gemspec => "ruby:gemspec"
@@ -0,0 +1,15 @@
+unless Object.const_defined? :Plymouth
+ $:.unshift File.expand_path '../../lib', __FILE__
+end
+
+require 'plymouth'
+
+describe Array do
+ before do
+ @array = [1]
+ end
+
+ it 'should be empty' do
+ @array.empty?.should == true
+ end
+end
@@ -0,0 +1,17 @@
+unless Object.const_defined? :Plymouth
+ $:.unshift File.expand_path '../../lib', __FILE__
+end
+
+require 'minitest/autorun'
+require 'minitest/spec'
+require 'plymouth'
+
+describe Array do
+ before do
+ @array = [1]
+ end
+
+ it 'should be empty' do
+ @array.empty?.must_equal true
+ end
+end
@@ -0,0 +1,15 @@
+unless Object.const_defined? :Plymouth
+ $:.unshift File.expand_path '../../lib', __FILE__
+end
+
+require 'plymouth'
+
+describe Array do
+ before do
+ @array = [1]
+ end
+
+ it 'should be empty' do
+ @array.empty?.should == true
+ end
+end
View
@@ -6,39 +6,54 @@
EE.enabled = true
+message = nil
+
+Pry.config.commands.before_command("whereami") do
+ output.puts
+ output.puts "#{Pry::Helpers::Text.bold("Test failure:")} #{message}"
+end
+
if defined?(Bacon)
EE.intercept do |frame, ex|
- ex.is_a?(Bacon::Error) && frame.method_name != :run_requirement
+
+ if ex.is_a?(Bacon::Error) && frame.method_name != :run_requirement
+ message = ex
+ true
+ else
+ false
+ end
end.skip_until { |frame| frame.klass == Bacon::Context }
elsif defined?(RSpec)
EE.intercept do |frame, ex|
- ex.class.name =~ /RSpec::Expectations::ExpectationNotMetError/
+
+ if ex.class.name =~ /RSpec::Expectations::ExpectationNotMetError/
+ message = ex
+ true
+ else
+ false
+ end
+
end.skip_until do |frame|
frame.klass.name =~ /RSpec::Core::ExampleGroup::Nested/
end
elsif defined?(MiniTest)
- EE.intercept(MiniTest::Assertion).skip_until do |frame|
+ EE.intercept do |frame, ex|
+
+ if ex.is_a?(MiniTest::Assertion)
+ message = ex
+ true
+ else
+ false
+ end
+
+ end.skip_until do |frame|
frame.method_name =~ /^test_/
end
-
-# elsif defined?(Riot)
-# EE.enabled = false
-# class Riot::Assertion
-# private
-# alias_method :oh_my_old_assert, :assert
-# def assert(*args, &block)
-# result = oh_my_old_assert(*args, &block)
-# if result.first == :fail || result.first == :error
-# Pry.start binding, :call_stack => binding.callers
-# end
-
-# result
-# end
-# end
end
+
@@ -1,3 +1,3 @@
module Plymouth
- VERSION = "0.1.1"
+ VERSION = "0.2.0"
end
View
@@ -2,32 +2,36 @@
Gem::Specification.new do |s|
s.name = "plymouth"
- s.version = "0.1.1"
+ s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
s.date = "2012-02-08"
- s.description = "FIX ME"
+ s.description = "Start an interactive session when a test fails"
s.email = "jrmair@gmail.com"
- s.files = [".gemtest", ".gitignore", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/plymouth.rb", "lib/plymouth/version.rb", "plymouth.gemspec", "test/test.rb"]
+ s.files = [".gemtest", ".gitignore", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example_bacon.rb", "examples/example_minitest.rb", "examples/example_rspec.rb", "lib/plymouth.rb", "lib/plymouth/version.rb", "plymouth.gemspec", "test/test.rb"]
s.homepage = "http://github.com/banister/plymouth"
s.require_paths = ["lib"]
- s.rubygems_version = "1.8.11"
- s.summary = "FIX ME"
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
+ s.rubygems_version = "1.8.15"
+ s.summary = "Start an interactive session when a test fails"
s.test_files = ["test/test.rb"]
if s.respond_to? :specification_version then
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_runtime_dependency(%q<pry-exception_explorer>, [">= 0"])
+ s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_development_dependency(%q<rspec>, [">= 0"])
else
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_dependency(%q<pry-exception_explorer>, [">= 0"])
+ s.add_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
end
else
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_dependency(%q<pry-exception_explorer>, [">= 0"])
+ s.add_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
end
end

0 comments on commit 7493529

Please sign in to comment.