From 213e4122d3e92e58fb94cee02b94da9ce3137339 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 8 Jun 2014 13:41:55 -0400 Subject: [PATCH] Extract RSpec support to another gem --- .travis.yml | 1 - Rakefile | 3 +- Rakefile.rspec-core | 9 - acceptance/rspec_example_spec.rb | 24 --- acceptance/verification_spec.rb | 2 +- acceptance/verification_spec_rspec-core.rb | 29 --- ci_reporter.gemspec | 4 +- gemfiles/Gemfile.rspec | 5 - lib/ci/reporter/rake/rspec.rb | 31 --- lib/ci/reporter/rake/rspec_loader.rb | 6 - lib/ci/reporter/rspec.rb | 177 ------------------ spec/ci/reporter/rake/rake_tasks_spec.rb | 2 +- .../rake/rake_tasks_spec_rspec-core.rb | 36 ---- spec/ci/reporter/rspec_spec.rb | 155 --------------- stub.rake | 1 - tasks/ci_reporter.rake | 2 - 16 files changed, 5 insertions(+), 482 deletions(-) delete mode 100644 Rakefile.rspec-core delete mode 100644 acceptance/rspec_example_spec.rb delete mode 100644 acceptance/verification_spec_rspec-core.rb delete mode 100644 gemfiles/Gemfile.rspec delete mode 100644 lib/ci/reporter/rake/rspec.rb delete mode 100644 lib/ci/reporter/rake/rspec_loader.rb delete mode 100644 lib/ci/reporter/rspec.rb delete mode 100644 spec/ci/reporter/rake/rake_tasks_spec_rspec-core.rb delete mode 100644 spec/ci/reporter/rspec_spec.rb diff --git a/.travis.yml b/.travis.yml index 75a63d8..470a767 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ gemfile: - Gemfile - gemfiles/Gemfile.minitest - gemfiles/Gemfile.test-unit - - gemfiles/Gemfile.rspec branches: only: diff --git a/Rakefile b/Rakefile index 34f667f..09ceb7d 100644 --- a/Rakefile +++ b/Rakefile @@ -25,7 +25,6 @@ begin p.test_globs = ["spec/**/*_spec.rb"] p.extra_deps << [ 'builder', '>= 2.1.2' ] p.extra_dev_deps << [ 'hoe-git', '~> 1.5.0' ] - p.extra_dev_deps << [ 'rspec', '> 2.0.0' ] p.extra_dev_deps << [ 'test-unit', '> 2.4.9' ] p.extra_dev_deps << [ 'minitest', '~> 2.2.0' ] p.clean_globs += ["spec/reports", "acceptance/reports"] @@ -47,7 +46,7 @@ namespace :generate do deps = [:clean] - ['test-unit', 'minitest', 'rspec-core'].each do |gem| + ['test-unit', 'minitest'].each do |gem| if Gem.loaded_specs[gem] load "Rakefile.#{gem}" deps << "generate:#{gem}" diff --git a/Rakefile.rspec-core b/Rakefile.rspec-core deleted file mode 100644 index e06349c..0000000 --- a/Rakefile.rspec-core +++ /dev/null @@ -1,9 +0,0 @@ -require 'ci/reporter/internal' -include CI::Reporter::Internal - -namespace :generate do - task 'rspec-core' do - rspec = "#{Gem.loaded_specs['rspec-core'].gem_dir}/exe/rspec" - run_ruby_acceptance "-S #{rspec} --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb" - end -end diff --git a/acceptance/rspec_example_spec.rb b/acceptance/rspec_example_spec.rb deleted file mode 100644 index b6d434e..0000000 --- a/acceptance/rspec_example_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -#-- -# Copyright (c) 2006-2012 Nick Sieger -# See the file LICENSE.txt included with the distribution for -# software license details. -#++ - -describe "RSpec example" do - it "should succeed" do - true.should be true - nil.should be_nil - end - - it "should fail" do - true.should be false - end - - it "should be pending" - - describe "nested" do - it "should succeed" do - true.should be true - end - end -end diff --git a/acceptance/verification_spec.rb b/acceptance/verification_spec.rb index 5211e20..c28f071 100644 --- a/acceptance/verification_spec.rb +++ b/acceptance/verification_spec.rb @@ -9,6 +9,6 @@ ACCEPTANCE_DIR = File.dirname(__FILE__) REPORTS_DIR = ACCEPTANCE_DIR + '/reports' -['test-unit', 'minitest', 'rspec-core'].each do |gem| +['test-unit', 'minitest'].each do |gem| load ACCEPTANCE_DIR + "/verification_spec_#{gem}.rb" if Gem.loaded_specs[gem] end diff --git a/acceptance/verification_spec_rspec-core.rb b/acceptance/verification_spec_rspec-core.rb deleted file mode 100644 index ee1bf64..0000000 --- a/acceptance/verification_spec_rspec-core.rb +++ /dev/null @@ -1,29 +0,0 @@ -describe "RSpec acceptance" do - it "should generate two XML files" do - File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')).should == true - File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')).should == true - end - - it "should have two tests and one failure" do - doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')) do |f| - REXML::Document.new(f) - end - doc.root.attributes["errors"].should == "0" - doc.root.attributes["failures"].should == "1" - doc.root.attributes["tests"].should == "3" - doc.root.elements.to_a("/testsuite/testcase").size.should == 3 - failures = doc.root.elements.to_a("/testsuite/testcase/failure") - failures.size.should == 1 - failures.first.attributes["type"].should =~ /ExpectationNotMetError/ - end - - it "should have one test in the nested example report" do - doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')) do |f| - REXML::Document.new(f) - end - doc.root.attributes["errors"].should == "0" - doc.root.attributes["failures"].should == "0" - doc.root.attributes["tests"].should == "1" - doc.root.elements.to_a("/testsuite/testcase").size.should == 1 - end -end diff --git a/ci_reporter.gemspec b/ci_reporter.gemspec index 5553add..6bd8107 100644 --- a/ci_reporter.gemspec +++ b/ci_reporter.gemspec @@ -10,14 +10,14 @@ Gem::Specification.new do |s| s.description = "CI::Reporter is an add-on to Test::Unit, RSpec and Cucumber that allows you to generate XML reports of your test, spec and/or feature runs. The resulting files can be read by a continuous integration system that understands Ant's JUnit report XML format, thus allowing your CI system to track test/spec successes and failures." s.email = "nick@nicksieger.com" s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc"] - s.files = [".gemtest", ".hoerc", ".rspec", ".travis.yml", "Gemfile", "History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "Rakefile", "acceptance/minitest_example_test.rb", "acceptance/rspec_example_spec.rb", "acceptance/test_unit_example_test.rb", "acceptance/verification_spec.rb", "ci_reporter.gemspec", "lib/ci/reporter/core.rb", "lib/ci/reporter/minitest.rb", "lib/ci/reporter/rake/minitest.rb", "lib/ci/reporter/rake/minitest_loader.rb", "lib/ci/reporter/rake/rspec.rb", "lib/ci/reporter/rake/rspec_loader.rb", "lib/ci/reporter/rake/test_unit.rb", "lib/ci/reporter/rake/test_unit_loader.rb", "lib/ci/reporter/rake/utils.rb", "lib/ci/reporter/report_manager.rb", "lib/ci/reporter/rspec.rb", "lib/ci/reporter/test_suite.rb", "lib/ci/reporter/test_unit.rb", "lib/ci/reporter/version.rb", "spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/rspec_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb", "spec/spec_helper.rb", "stub.rake", "tasks/ci_reporter.rake"] + s.files = [".gemtest", ".hoerc", ".rspec", ".travis.yml", "Gemfile", "History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "Rakefile", "acceptance/minitest_example_test.rb", "acceptance/test_unit_example_test.rb", "acceptance/verification_spec.rb", "ci_reporter.gemspec", "lib/ci/reporter/core.rb", "lib/ci/reporter/minitest.rb", "lib/ci/reporter/rake/minitest.rb", "lib/ci/reporter/rake/minitest_loader.rb", "lib/ci/reporter/rake/test_unit.rb", "lib/ci/reporter/rake/test_unit_loader.rb", "lib/ci/reporter/rake/utils.rb", "lib/ci/reporter/report_manager.rb", "lib/ci/reporter/test_suite.rb", "lib/ci/reporter/test_unit.rb", "lib/ci/reporter/version.rb", "spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb", "spec/spec_helper.rb", "stub.rake", "tasks/ci_reporter.rake"] s.homepage = "https://github.com/nicksieger/ci_reporter" s.licenses = ["MIT"] s.rdoc_options = ["--main", "README.rdoc", "-SHN", "-f", "darkfish"] s.require_paths = ["lib"] s.rubygems_version = "1.8.23" s.summary = "CI::Reporter allows you to generate reams of XML for use with continuous integration systems." - s.test_files = ["spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/rspec_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb"] + s.test_files = ["spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb"] if s.respond_to? :specification_version then s.specification_version = 3 diff --git a/gemfiles/Gemfile.rspec b/gemfiles/Gemfile.rspec deleted file mode 100644 index 6bb466d..0000000 --- a/gemfiles/Gemfile.rspec +++ /dev/null @@ -1,5 +0,0 @@ -source 'https://rubygems.org' - -gem 'rake' -gem 'rspec', '~> 2.0' -gem 'ci_reporter', path: '..' diff --git a/lib/ci/reporter/rake/rspec.rb b/lib/ci/reporter/rake/rspec.rb deleted file mode 100644 index 54a0d1b..0000000 --- a/lib/ci/reporter/rake/rspec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2006-2012 Nick Sieger -# See the file LICENSE.txt included with the distribution for -# software license details. - -require File.expand_path('../utils', __FILE__) - -namespace :ci do - namespace :setup do - task :spec_report_cleanup do - rm_rf ENV["CI_REPORTS"] || "spec/reports" - end - - task :rspec => :spec_report_cleanup do - spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"), - "--format", "CI::Reporter::RSpec"].join(" ") - ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}" - end - - task :rspecdoc => :spec_report_cleanup do - spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"), - "--format", "CI::Reporter::RSpecDoc"].join(" ") - ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}" - end - - task :rspecbase => :spec_report_cleanup do - spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"), - "--format", "CI::Reporter::RSpecBase"].join(" ") - ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}" - end - end -end diff --git a/lib/ci/reporter/rake/rspec_loader.rb b/lib/ci/reporter/rake/rspec_loader.rb deleted file mode 100644 index f471d32..0000000 --- a/lib/ci/reporter/rake/rspec_loader.rb +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) 2006-2012 Nick Sieger -# See the file LICENSE.txt included with the distribution for -# software license details. - -$: << File.dirname(__FILE__) + "/../../.." -require 'ci/reporter/rspec' diff --git a/lib/ci/reporter/rspec.rb b/lib/ci/reporter/rspec.rb deleted file mode 100644 index 53e7122..0000000 --- a/lib/ci/reporter/rspec.rb +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright (c) 2006-2012 Nick Sieger -# See the file LICENSE.txt included with the distribution for -# software license details. - -require 'ci/reporter/core' - -module CI - module Reporter - module RSpecFormatters - require 'rspec/core/formatters/base_formatter' - require 'rspec/core/formatters/progress_formatter' - require 'rspec/core/formatters/documentation_formatter' - BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter - ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter - DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter - # See https://github.com/nicksieger/ci_reporter/issues/76 and - # https://github.com/nicksieger/ci_reporter/issues/80 - require 'rspec/core/version' - RSpec_2_12_0_bug = (::RSpec::Core::Version::STRING == '2.12.0' && - !BaseFormatter.instance_methods(false).map(&:to_s).include?("format_backtrace")) - end - - # Wrapper around a RSpec error or failure to be used by the test suite to interpret results. - class RSpec2Failure - attr_reader :exception - - def initialize(example, formatter) - @formatter = formatter - @example = example - if @example.respond_to?(:execution_result) - @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered] - else - @exception = @example.metadata[:execution_result][:exception] - end - end - - def name - @exception.class.name - end - - def message - @exception.message - end - - def failure? - exception.is_a?(::RSpec::Expectations::ExpectationNotMetError) - end - - def error? - !failure? - end - - def location - output = [] - output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/ - output.push @exception.message - - format_metadata = RSpecFormatters::RSpec_2_12_0_bug ? @example.metadata : @example - - [@formatter.format_backtrace(@exception.backtrace, format_metadata)].flatten.each do |backtrace_info| - backtrace_info.lines.each do |line| - output.push " #{line}" - end - end - output.join "\n" - end - end - - # Custom +RSpec+ formatter used to hook into the spec runs and capture results. - class RSpec - attr_accessor :report_manager - attr_accessor :formatter - def initialize(*args) - @formatter ||= RSpecFormatters::ProgressFormatter.new(*args) - @report_manager = ReportManager.new("spec") - @suite = nil - end - - def example_group_started(example_group) - @formatter.example_group_started(example_group) - new_suite(description_for(example_group)) - end - - def example_started(name_or_example) - @formatter.example_started(name_or_example) - spec = TestCase.new - @suite.testcases << spec - spec.start - end - - def example_failed(name_or_example, *rest) - @formatter.example_failed(name_or_example, *rest) - - # In case we fail in before(:all) - example_started(name_or_example) if @suite.testcases.empty? - - failure = RSpec2Failure.new(name_or_example, @formatter) - - spec = @suite.testcases.last - spec.finish - spec.name = description_for(name_or_example) - spec.failures << failure - end - - def example_passed(name_or_example) - @formatter.example_passed(name_or_example) - spec = @suite.testcases.last - spec.finish - spec.name = description_for(name_or_example) - end - - def example_pending(*args) - @formatter.example_pending(*args) - name = description_for(args[0]) - spec = @suite.testcases.last - spec.finish - spec.name = "#{name} (PENDING)" - spec.skipped = true - end - - def dump_summary(*args) - @formatter.dump_summary(*args) - write_report - @formatter.dump_failures - end - - def respond_to?(*args) - @formatter.respond_to?(*args) - end - - # Pass through other methods to RSpec formatter for compatibility - def method_missing(meth,*args,&block) - @formatter.send(meth,*args,&block) - end - - private - def description_for(name_or_example) - if name_or_example.respond_to?(:full_description) - name_or_example.full_description - elsif name_or_example.respond_to?(:metadata) - name_or_example.metadata[:example_group][:full_description] - elsif name_or_example.respond_to?(:description) - name_or_example.description - else - "UNKNOWN" - end - end - - def write_report - if @suite - @suite.finish - @report_manager.write_report(@suite) - end - end - - def new_suite(name) - write_report if @suite - @suite = TestSuite.new name - @suite.start - end - end - - class RSpecDoc < RSpec - def initialize(*args) - @formatter = RSpecFormatters::DocFormatter.new(*args) - super - end - end - - class RSpecBase < RSpec - def initialize(*args) - @formatter = RSpecFormatters::BaseFormatter.new(*args) - super - end - end - end -end diff --git a/spec/ci/reporter/rake/rake_tasks_spec.rb b/spec/ci/reporter/rake/rake_tasks_spec.rb index a3380ad..5dc68e6 100644 --- a/spec/ci/reporter/rake/rake_tasks_spec.rb +++ b/spec/ci/reporter/rake/rake_tasks_spec.rb @@ -9,6 +9,6 @@ include CI::Reporter::Internal THIS_SPEC_DIR = File.dirname(__FILE__) -['test-unit', 'rspec-core'].each do |gem| +['test-unit'].each do |gem| load THIS_SPEC_DIR + "/rake_tasks_spec_#{gem}.rb" end diff --git a/spec/ci/reporter/rake/rake_tasks_spec_rspec-core.rb b/spec/ci/reporter/rake/rake_tasks_spec_rspec-core.rb deleted file mode 100644 index fefed1e..0000000 --- a/spec/ci/reporter/rake/rake_tasks_spec_rspec-core.rb +++ /dev/null @@ -1,36 +0,0 @@ -describe "ci_reporter ci:setup:rspec task" do - before(:each) do - @rake = Rake::Application.new - Rake.application = @rake - load CI_REPORTER_LIB + '/ci/reporter/rake/rspec.rb' - save_env "CI_REPORTS" - save_env "SPEC_OPTS" - ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf" - end - after(:each) do - restore_env "SPEC_OPTS" - restore_env "CI_REPORTS" - Rake.application = nil - end - - it "should set ENV['SPEC_OPTS'] to include rspec formatter args" do - @rake["ci:setup:rspec"].invoke - ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpec/ - end - - it "should set ENV['SPEC_OPTS'] to include rspec doc formatter if task is ci:setup:rspecdoc" do - @rake["ci:setup:rspecdoc"].invoke - ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecDoc/ - end - - it "should set ENV['SPEC_OPTS'] to include rspec base formatter if task is ci:setup:rspecbase" do - @rake["ci:setup:rspecbase"].invoke - ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecBase/ - end - - it "should append to ENV['SPEC_OPTS'] if it already contains a value" do - ENV["SPEC_OPTS"] = "somevalue".freeze - @rake["ci:setup:rspec"].invoke - ENV["SPEC_OPTS"].should =~ /somevalue.*--require.*rspec_loader.*--format.*CI::Reporter::RSpec/ - end -end diff --git a/spec/ci/reporter/rspec_spec.rb b/spec/ci/reporter/rspec_spec.rb deleted file mode 100644 index 06e9148..0000000 --- a/spec/ci/reporter/rspec_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright (c) 2006-2013 Nick Sieger -# See the file LICENSE.txt included with the distribution for -# software license details. - -if Gem.loaded_specs['rspec-core'] - -require File.dirname(__FILE__) + "/../../spec_helper.rb" -require 'ci/reporter/rspec' -require 'stringio' - -describe "The RSpec reporter" do - before(:each) do - @error = double("error") - @error.stub(:expectation_not_met?).and_return(false) - @error.stub(:pending_fixed?).and_return(false) - @error.stub(:exception).and_return(StandardError.new) - @report_mgr = double("report manager") - @options = double("options") - @args = [@options, StringIO.new("")] - @args.shift unless defined?(::Spec) && ::Spec::VERSION::MAJOR == 1 && ::Spec::VERSION::MINOR >= 1 - @fmt = CI::Reporter::RSpec.new *@args - @fmt.report_manager = @report_mgr - @formatter = double("formatter") - @fmt.formatter = @formatter - end - - it "should use a progress bar formatter by default" do - fmt = CI::Reporter::RSpec.new *@args - fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::ProgressFormatter) - end - - it "should use a specdoc formatter for RSpecDoc" do - fmt = CI::Reporter::RSpecDoc.new *@args - fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::DocFormatter) - end - - def rspec2_failing_example(exception_text) - double('RSpec2.2 Example', - :execution_result => { - :exception => StandardError.new(exception_text) - }, - :metadata => { - :example_group => { - :full_description => "description" - } - }) - end - - it "should create a test suite with one success, one failure, and one pending" do - @report_mgr.should_receive(:write_report) do |suite| - suite.testcases.length.should == 3 - suite.testcases[0].should_not be_failure - suite.testcases[0].should_not be_error - suite.testcases[1].should be_error - suite.testcases[2].name.should =~ /\(PENDING\)/ - end - - example_group = double "example group" - example_group.stub(:description).and_return "A context" - - @formatter.should_receive(:start).with(3) - @formatter.should_receive(:example_group_started).with(example_group) - @formatter.should_receive(:example_started).exactly(3).times - @formatter.should_receive(:example_passed).once - @formatter.should_receive(:example_failed).once - @formatter.should_receive(:example_pending).once - @formatter.should_receive(:start_dump).once - @formatter.should_receive(:dump_failure).once - @formatter.should_receive(:dump_summary).once - @formatter.should_receive(:dump_pending).once - @formatter.should_receive(:dump_failures).once - @formatter.should_receive(:close).once - - @fmt.start(3) - @fmt.example_group_started(example_group) - @fmt.example_started("should pass") - @fmt.example_passed("should pass") - @fmt.example_started("should fail") - @fmt.example_failed(rspec2_failing_example("should fail"), 1, @error) - @fmt.example_started("should be pending") - @fmt.example_pending("A context", "should be pending", "Not Yet Implemented") - @fmt.start_dump - @fmt.dump_failure(1, double("failure")) - @fmt.dump_summary(0.1, 3, 1, 1) - @fmt.dump_pending - @fmt.close - end - - it "should use the example #description method when available" do - group = double "example group" - group.stub(:description).and_return "group description" - example = double "example" - example.stub(:description).and_return "should do something" - - @formatter.should_receive(:start) - @formatter.should_receive(:example_group_started).with(group) - @formatter.should_receive(:example_started).with(example).once - @formatter.should_receive(:example_passed).once - @formatter.should_receive(:dump_summary) - @formatter.should_receive(:dump_failures).once - @report_mgr.should_receive(:write_report) do |suite| - suite.testcases.last.name.should == "should do something" - end - - @fmt.start(2) - @fmt.example_group_started(group) - @fmt.example_started(example) - @fmt.example_passed(example) - @fmt.dump_summary(0.1, 1, 0, 0) - end - - it "should create a test suite with failure in before(:all)" do - example_group = double "example group" - example_group.stub(:description).and_return "A context" - - @formatter.should_receive(:start) - @formatter.should_receive(:example_group_started).with(example_group) - @formatter.should_receive(:example_started).once - @formatter.should_receive(:example_failed).once - @formatter.should_receive(:dump_summary) - @formatter.should_receive(:dump_failures).once - @report_mgr.should_receive(:write_report) - - @fmt.start(2) - @fmt.example_group_started(example_group) - @fmt.example_failed(rspec2_failing_example("should fail"), 1, @error) - @fmt.dump_summary(0.1, 1, 0, 0) - end - - describe 'RSpec2Failure' do - before(:each) do - @formatter = double "formatter" - @formatter.should_receive(:format_backtrace).and_return("backtrace") - @rspec20_example = double('RSpec2.0 Example', - :execution_result => {:exception_encountered => StandardError.new('rspec2.0 ftw')}, - :metadata => {}) - - @rspec22_example = rspec2_failing_example('rspec2.2 ftw') - end - - it 'should handle rspec (< 2.2) execution results' do - failure = CI::Reporter::RSpec2Failure.new(@rspec20_example, @formatter) - failure.name.should_not be_nil - failure.message.should == 'rspec2.0 ftw' - failure.location.should_not be_nil - end - it 'should handle rspec (>= 2.2) execution results' do - failure = CI::Reporter::RSpec2Failure.new(@rspec22_example, @formatter) - failure.name.should_not be_nil - failure.message.should == 'rspec2.2 ftw' - failure.location.should_not be_nil - end - end -end -end diff --git a/stub.rake b/stub.rake index 9b1840c..1c4ae29 100644 --- a/stub.rake +++ b/stub.rake @@ -8,7 +8,6 @@ # rake -f /path/to/ci_reporter/lib/ci/reporter/rake/stub.rake ci:setup:rspec default # -load File.dirname(__FILE__) + '/lib/ci/reporter/rake/rspec.rb' load File.dirname(__FILE__) + '/lib/ci/reporter/rake/test_unit.rb' load File.dirname(__FILE__) + '/lib/ci/reporter/rake/minitest.rb' load 'Rakefile' diff --git a/tasks/ci_reporter.rake b/tasks/ci_reporter.rake index 55fb836..b65e61f 100644 --- a/tasks/ci_reporter.rake +++ b/tasks/ci_reporter.rake @@ -7,12 +7,10 @@ begin rescue Gem::LoadError $: << File.dirname(__FILE__) + "/../lib" end -require 'ci/reporter/rake/rspec' require 'ci/reporter/rake/test_unit' require 'ci/reporter/rake/minitest' namespace :ci do - task :setup_rspec => "ci:setup:rspec" task :setup_testunit => "ci:setup:testunit" task :setup_minitest => "ci:setup:minitest" end