Skip to content

Commit

Permalink
Merge pull request #63 from jmgarnier/master
Browse files Browse the repository at this point in the history
Add TB_RSPEC_FORMATTER env variable to specify RSpec format
  • Loading branch information
Marko Bogdanović committed Jun 25, 2018
2 parents 9d392c7 + 3cd76b9 commit 2fe7ad0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -122,16 +122,16 @@ bundle exec rspec --format documentation --format json --out /home/<user>/rspec_
```

Optionally, you can pass additional RSpec flags with the `TB_RSPEC_OPTIONS`
environment variable:
environment variable. You can also set a RSpec formatter with the `TB_RSPEC_FORMATTER` environment variable.
Default formatter is `documentation`.

``` bash
TB_RSPEC_OPTIONS='--fail-fast=3' rspec_booster --job 4/32
```

The above command will execute:

Example:
``` bash
bundle exec rspec --fail-fast=3 --format documentation --format json --out /home/<user>/rspec_report.json <file_list>
TB_RSPEC_OPTIONS='--fail-fast=3' TB_RSPEC_FORMATTER=Fivemat rspec_booster --job 4/32
# will execute:
bundle exec rspec --fail-fast=3 --format Fivemat --format json --out /home/<user>/rspec_report.json <file_list>
```

## Cucumber Booster
Expand Down
7 changes: 5 additions & 2 deletions lib/test_boosters/boosters/rspec.rb
Expand Up @@ -25,8 +25,11 @@ def command
end

def rspec_options
# rubocop:disable LineLength
@rspec_options ||= "#{ENV["TB_RSPEC_OPTIONS"]} --format documentation --require #{formatter_path} --format SemaphoreFormatter --out #{report_path}"
@rspec_options ||= begin
output_formatter = ENV.fetch("TB_RSPEC_FORMATTER", "documentation")
# rubocop:disable LineLength
"#{ENV["TB_RSPEC_OPTIONS"]} --format #{output_formatter} --require #{formatter_path} --format SemaphoreFormatter --out #{report_path}"
end
end

def report_path
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/test_boosters/boosters/rspec_spec.rb
Expand Up @@ -45,6 +45,28 @@
end
end

describe "#rspec_options" do
context "when TB_RSPEC_FORMATTER environment variable is not set" do
it "returns the SemaphoreFormatter with --format documentation" do
expect(booster.rspec_options).to include("--format documentation")
end
end

context "when TB_RSPEC_FORMATTER environment variable is set" do
around do |example|
ENV["TB_RSPEC_FORMATTER"] = "Fivemat"
example.run
ENV.delete("TB_RSPEC_FORMATTER")
end

it "returns the SemaphoreFormatter but removes --format documentation
and uses the option specified in env variable" do
expect(booster.rspec_options).not_to include("--format documentation")
expect(booster.rspec_options).to include("--format Fivemat")
end
end
end

describe "#split_configuration_path" do
before { ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] = "/tmp/path.txt" }

Expand Down

0 comments on commit 2fe7ad0

Please sign in to comment.