Permalink
Browse files

Updated autotest regular expression and consolidate failures to work …

…directly from text formatter

- Closes #97.
  • Loading branch information...
Dave Newman authored and dchelimsky committed Aug 3, 2010
1 parent 1d57042 commit 6f6ea2102dfd9bae4476c3e3fafaf05f83c8d4a7
Showing with 18 additions and 27 deletions.
  1. +3 −3 lib/autotest/rspec2.rb
  2. +14 −23 spec/autotest/failed_results_re_spec.rb
  3. +1 −1 spec/autotest/rspec_spec.rb
View
@@ -10,7 +10,7 @@ def initialize
super
clear_mappings
setup_rspec_project_mappings
- self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m
+ self.failed_results_re = /^\s*\d\)\s(.*?$\n.*?$).*?#\s(.*?):/m
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
end
@@ -29,8 +29,8 @@ def setup_rspec_project_mappings
def consolidate_failures(failed)
filters = new_hash_of_arrays
failed.each do |spec, trace|
- if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/
- filters[$2] << spec
+ if trace =~ /(.*spec\.rb)/
+ filters[$1] << spec
end
end
return filters
@@ -1,31 +1,22 @@
require "spec_helper"
describe "failed_results_re for autotest" do
- it "should match a failure" do
- re = Autotest::Rspec2.new.failed_results_re
- re =~ "1)\n'this example' FAILED\nreason\n/path.rb:37:\n\n"
- $1.should == "this example"
- $2.should == "reason\n/path.rb:37:"
- end
-
- it "should match a failure when matcher outputs multiple lines" do
- re = Autotest::Rspec2.new.failed_results_re
- re =~ "1)\n'other example' FAILED\n\nreason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:\n\n"
- $1.should == "other example"
- $2.should == "reason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:"
+ let(:output) { StringIO.new }
+ let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
+ let(:example_output) do
+ group = RSpec::Core::ExampleGroup.describe("group name")
+ example = group.example("example name") { "this".should eq("that") }
+ group.run_all(formatter)
+ RSpec.configuration.stub(:color_enabled?) { false }
+ formatter.dump_failures
+ output.string
end
-
- it "should match an Error" do
+
+ it "should match a failure" do
re = Autotest::Rspec2.new.failed_results_re
- re =~ "1)\nRuntimeError in 'this example'\nreason\n/path.rb:37:\n\n"
- $1.should == "this example"
- $2.should == "reason\n/path.rb:37:"
+ re =~ example_output
+ $1.should == "group name example name\n Failure/Error: example = group.example(\"example name\") { \"this\".should eq(\"that\") }"
+ $2.should == "./spec/autotest/failed_results_re_spec.rb"
end
- it "should match an Error that doesn't end in Error" do
- re = Autotest::Rspec2.new.failed_results_re
- re =~ "1)\nInvalidArgument in 'this example'\nreason\n/path.rb:37:\n\n"
- $1.should == "this example"
- $2.should == "reason\n/path.rb:37:"
- end
end
@@ -78,7 +78,7 @@
failures = [
[
"false should be false",
- "expected: true,\n got: false (using ==)\n#{@spec_file}:203:"
+ "#{@spec_file}"
]
]
@rspec_autotest.consolidate_failures(failures).should == {

0 comments on commit 6f6ea21

Please sign in to comment.