File: verbose_logger_spec.rb

package info (click to toggle)
ruby-parallel-tests 5.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 760 kB
  • sloc: ruby: 5,479; javascript: 16; makefile: 4
file content (52 lines) | stat: -rw-r--r-- 1,289 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
46
47
48
49
50
51
52
# frozen_string_literal: true

require 'spec_helper'

describe ParallelTests::RSpec::VerboseLogger do
  def run(command)
    result = IO.popen(command, err: [:child, :out], &:read)
    raise "FAILED: #{result}" unless $?.success?
    result
  end

  it 'outputs verbose information' do
    repo_root = Dir.pwd

    use_temporary_directory do
      # setup simple structure
      FileUtils.mkdir "spec"

      File.write "spec/foo_spec.rb", <<-RUBY
        describe "Foo" do
          it "foo" do
            sleep 0.5
            expect(true).to be(true)
          end
        end
      RUBY

      File.write "spec/bar_spec.rb", <<-RUBY
        describe "Bar" do
          it "bar" do
            sleep 0.25111
            expect(true).to be(true)
          end
        end
      RUBY

      result = run [
        "ruby",
        "#{repo_root}/bin/parallel_rspec",
        "-n", "2",
        "--",
        "--format", "ParallelTests::RSpec::VerboseLogger",
        "--"
      ]

      expect(result).to match(/^\[\d+\] \[(1|2)\] \[STARTED\] Foo foo$/)
      expect(result).to match(/^\[\d+\] \[(1|2)\] \[PASSED\] Foo foo$/)
      expect(result).to match(/^\[\d+\] \[(1|2)\] \[STARTED\] Bar bar$/)
      expect(result).to match(/^\[\d+\] \[(1|2)\] \[PASSED\] Bar bar$/)
    end
  end
end