Sha256: ffa7a6790dcceac53c6642a59cd70efc12dace72d2906ad17e24f4d4a9bcc6a9

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

describe "failed_results_re for autotest" do
  def run_example
    group = RSpec::Core::ExampleGroup.describe("group")
    group.example("example") { yield }
    io = StringIO.new
    run_group(group, io)
    io.string
  end

  if RSpec::Core::Version::STRING.to_f >= 3
    def run_group(group, io)
      options = RSpec::Core::ConfigurationOptions.new([])
      config  = RSpec::Core::Configuration.new
      runner  = RSpec::Core::Runner.new(options, config)
      runner.setup(io, io)
      runner.run_specs([group])
    end
  else
    def run_group(group, io)
      formatter = RSpec::Core::Formatters::BaseTextFormatter.new(io)
      reporter = RSpec::Core::Reporter.new(formatter)
      group.run(reporter)
      reporter.report(1, nil) { }
    end
  end

  shared_examples "autotest failed_results_re" do
    it "matches a failure" do
      output = run_example { fail }
      expect(output).to match(Autotest::Rspec.new.failed_results_re)
      expect(output).to include(__FILE__.sub(File.expand_path('.'),'.'))
    end

    it "does not match when there are no failures" do
      output = run_example { } # pass
      expect(output).not_to match(Autotest::Rspec.new.failed_results_re)
      expect(output).not_to include(__FILE__.sub(File.expand_path('.'),'.'))
    end
  end

  context "with color enabled" do
    before do
      allow(RSpec.configuration).to receive(:color_enabled?).and_return(true)
    end

    include_examples "autotest failed_results_re"
  end

  context "with color disabled" do
    before do
      allow(RSpec.configuration).to receive(:color_enabled?).and_return(false)
    end

    include_examples "autotest failed_results_re"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-autotest-1.0.2 spec/autotest/failed_results_re_spec.rb
rspec-autotest-1.0.1 spec/autotest/failed_results_re_spec.rb
rspec-autotest-1.0.0 spec/autotest/failed_results_re_spec.rb
rspec-autotest-1.0.0.rc2 spec/autotest/failed_results_re_spec.rb