Browse files

Fixes for mSpec to coexist with autotest.

  • Loading branch information...
1 parent 45f2d6d commit 3904ff2fbb209b8c2d476bb3f4a4ea4825a16f6e Brian Ford committed Jan 28, 2008
View
2 .autotest
@@ -11,7 +11,7 @@ class Autotest
alias :old_make_test_cmd :make_test_cmd
def ruby
- "bin/ci"
+ "bin/ci -fu"
end
def make_test_cmd files_to_test
View
8 mspec/matchers/base.rb
@@ -1,9 +1,5 @@
-if ENV['PRETTY'] then
- require 'pp'
-else
- class Object
- alias :pretty_inspect :inspect
- end
+class Object
+ alias pretty_inspect inspect
end
class PositiveOperatorMatcher
View
2 mspec/runner/formatters/base.rb
@@ -183,11 +183,11 @@ def print_summary
def summary
unless @summarized
@out.print "\n\n"
- print_time
@exceptions.each_with_index do |r,i|
print_failure(i+1,r)
print_backtrace(r.exception)
end
+ print_time
print_summary
@summarized = true
end
View
29 mspec/runner/formatters/unit.rb
@@ -0,0 +1,29 @@
+require 'mspec/expectations'
+require 'mspec/runner/formatters/base'
+
+class UnitdiffFormatter < BaseFormatter
+ def after_it(msg)
+ if @current.exception
+ if failure? @current.exception
+ @out.print 'F'
+ else
+ @out.print 'E'
+ end
+ else
+ @out.print '.'
+ end
+ end
+
+ def summary
+ unless @summarized
+ @out.print "\n\n"
+ print_time
+ @exceptions.each_with_index do |r,i|
+ print_failure(i+1,r)
+ print_backtrace(r.exception)
+ end
+ print_summary
+ @summarized = true
+ end
+ end
+end
View
2 mspec/scripts/ci.rb
@@ -71,6 +71,8 @@ module CI
format = 'ImmediateFormatter'
when 'm', 'summary'
format = 'SummaryFormatter'
+ when 'u', 'unit'
+ format = 'UnitdiffFormatter'
else
puts "Unknown format: #{f}"
puts opts
View
2 mspec/scripts/mspec.rb
@@ -41,6 +41,8 @@ module MSpec
format = 'CIFormatter'
when 'i', 'immediate'
format = 'ImmediateFormatter'
+ when 'u', 'unit'
+ format = 'UnitdiffFormatter'
else
puts "Unknown format: #{f}"
puts opts
View
4 mspec/spec/matchers/base_spec.rb
@@ -21,7 +21,7 @@
it "raises an ExpectationNotMetError when expected =~ actual returns false" do
lambda {
PositiveOperatorMatcher.new('real') =~ /fake/
- }.should raise_error(ExpectationNotMetError, %(Expected "real" to match /fake/))
+ }.should raise_error(ExpectationNotMetError, %(Expected real to match (?-mix:fake)))
end
it "does not raise an exception when expected =~ actual returns true" do
@@ -107,7 +107,7 @@
it "raises an ExpectationNotMetError when expected =~ actual returns true" do
lambda {
NegativeOperatorMatcher.new('real') =~ /real/
- }.should raise_error(ExpectationNotMetError, %(Expected "real" not to match /real/))
+ }.should raise_error(ExpectationNotMetError, %(Expected real not to match (?-mix:real)))
end
it "does not raise an exception when expected =~ actual returns false" do
View
37 mspec/spec/runner/formatters/unit_spec.rb
@@ -0,0 +1,37 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../../runner/formatters/unit'
+
+describe UnitdiffFormatter do
+ before :each do
+ @out = CaptureOutput.new
+ @formatter = UnitdiffFormatter.new(@out)
+ @formatter.before_describe "describe"
+ @formatter.before_it "it"
+ @exception = Exception.new("something bad")
+ @formatter.exception @exception
+ @execution = SpecExecution.new
+ @execution.describe = "describe"
+ @execution.it = "it"
+ @execution.exception = @exception
+ end
+
+ it "responds to after_it with one argument" do
+ @formatter.after_it "after"
+ end
+
+ it "provides execution results when after_it is called" do
+ @formatter.before_it "it"
+ @formatter.after_it "first"
+ @out.should == "."
+ @formatter.before_it "it"
+ @formatter.exception @exception
+ @formatter.after_it "second"
+ @out.should == ".E"
+ end
+
+ it "provides a summary" do
+ @formatter.stub!(:print_time).and_return { @out.print "Finished in 33.000000 seconds\n\n" }
+ @formatter.summary
+ @out.should == "\n\nFinished in 33.000000 seconds\n\n1)\ndescribe it ERROR\nsomething bad: \n\n\n1 example, 0 expectations, 0 failures, 1 error\n"
+ end
+end
View
1 spec/ruby/1.8/spec_helper.rb
@@ -3,6 +3,7 @@
if ENV['MSPEC_RUNNER'] == '1'
require 'mspec/complete'
require 'mspec/mocks'
+ require 'pp'
else
require 'mspec/runner/guards'
require 'mspec/runner/shared'
View
1 spec/spec_helper.rb
@@ -3,6 +3,7 @@
if ENV['MSPEC_RUNNER'] == '1'
require 'mspec/complete'
require 'mspec/mocks'
+ require 'pp'
else
require 'mspec/runner/guards'
require 'mspec/runner/shared'

0 comments on commit 3904ff2

Please sign in to comment.