File: failure_logger_spec.rb

package info (click to toggle)
ruby-parallel-tests 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,280 kB
  • sloc: ruby: 5,381; javascript: 30; makefile: 4
file content (45 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'spec_helper'
require 'parallel_tests/gherkin/io'
require 'parallel_tests/cucumber/failures_logger'

describe ParallelTests::Cucumber::FailuresLogger do
  before do
    @output = OutputLogger.new([])
    allow(@output).to receive(:write)

    config = double('config', out_stream: @output, on_event: :test_run_finished)

    @logger1 = ParallelTests::Cucumber::FailuresLogger.new(config)
    @logger2 = ParallelTests::Cucumber::FailuresLogger.new(config)
    @logger3 = ParallelTests::Cucumber::FailuresLogger.new(config)

    @feature1 = double('feature', file: "feature/path/to/feature1.feature")
    @feature2 = double('feature', file: "feature/path/to/feature2.feature")
    @feature3 = double('feature', file: "feature/path/to/feature3.feature")

    @logger1.instance_variable_set("@failures", { @feature1.file => [1, 2, 3] })
    @logger2.instance_variable_set("@failures", { @feature2.file => [2, 4, 6] })
    @logger3.instance_variable_set("@failures", { @feature3.file => [3, 6, 9] })
  end

  it "should produce a list of lines for failing scenarios" do
    @logger1.done
    @logger2.done
    @logger3.done

    output_file_contents = @output.output.join("\n").concat("\n")

    expect(output_file_contents).to eq <<~END
      feature/path/to/feature1.feature:1\s
      feature/path/to/feature1.feature:2\s
      feature/path/to/feature1.feature:3\s
      feature/path/to/feature2.feature:2\s
      feature/path/to/feature2.feature:4\s
      feature/path/to/feature2.feature:6\s
      feature/path/to/feature3.feature:3\s
      feature/path/to/feature3.feature:6\s
      feature/path/to/feature3.feature:9\s
    END
  end
end