Skip to content

Commit

Permalink
feat(rspec): add bin script to test RSpec --options flag with custom …
Browse files Browse the repository at this point in the history
…options file

Related: KnapsackPro/knapsack_pro-ruby#234
  • Loading branch information
ArturT committed Dec 13, 2023
1 parent 5d9154b commit 675a118
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .rspec_custom.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--no-color
--require rails_helper
--format documentation
1 change: 1 addition & 0 deletions bin/knapsack_pro_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
'./bin/knapsack_pro_queue_rspec_default_formatter' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_profile_formatter' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_junit' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_junit_with_rspec_custom_options' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_log_dir' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_json' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
'./bin/knapsack_pro_queue_rspec_test_dir' => ['0 2 BUILD_ID', '1 2 BUILD_ID'],
Expand Down
18 changes: 18 additions & 0 deletions bin/knapsack_pro_queue_rspec_junit_with_rspec_custom_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

mkdir -p tmp/test-reports/rspec/queue_mode/

# must be exported to read value in below knapsack_pro command
export KNAPSACK_PRO_CI_NODE_INDEX=${1:-0}

CI_BUILD_ID=$(openssl rand -base64 32)

export RSPEC_CUSTOM_OPTIONS_ENABLED=true

KNAPSACK_PRO_ENDPOINT=http://api.knapsackpro.test:3000 \
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=a28ce51204d7c7dbd25c3352fea222cf \
KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
KNAPSACK_PRO_PROJECT_DIR=. \
KNAPSACK_PRO_CI_NODE_TOTAL=${2:-2} \
KNAPSACK_PRO_CI_NODE_BUILD_ID=${3:-$CI_BUILD_ID} \
bundle exec rake "knapsack_pro:queue:rspec[--options .rspec_custom.options --format RspecJunitFormatter --out tmp/test-reports/rspec/queue_mode/rspec_$KNAPSACK_PRO_CI_NODE_INDEX.xml]"
8 changes: 8 additions & 0 deletions spec/options_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://rspec.info/features/3-12/rspec-core/configuration/read-options-from-file/
describe 'RSpec Options' do
if ENV['RSPEC_CUSTOM_OPTIONS_ENABLED']
it { expect(RSpec.configuration.color_mode).to eq :off }
else
it { expect(RSpec.configuration.color_mode).to eq :automatic }
end
end

0 comments on commit 675a118

Please sign in to comment.