Skip to content

Commit a71d33d

Browse files
committed
Configure Knapsack Pro for RSpec
1 parent 75c06eb commit a71d33d

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ group :development, :test do
5151
gem "rubocop-rails-omakase", require: false
5252

5353
gem 'rspec-rails'
54+
55+
gem 'knapsack_pro'
5456
end
5557

5658
group :development do

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ GEM
140140
sshkit (>= 1.23.0, < 2.0)
141141
thor (~> 1.3)
142142
zeitwerk (>= 2.6.18, < 3.0)
143+
knapsack_pro (8.3.0)
144+
rake
143145
language_server-protocol (3.17.0.5)
144146
lint_roller (1.1.0)
145147
logger (1.7.0)
@@ -389,6 +391,7 @@ DEPENDENCIES
389391
importmap-rails
390392
jbuilder
391393
kamal
394+
knapsack_pro
392395
propshaft
393396
puma (>= 5.0)
394397
rails (~> 8.0.2)

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44
bundle install
55
```
66

7-
# RSpec
7+
# RSpec + Knapsack Pro
88

9-
Run:
9+
The RSpec `before(:suite)` hook is defined in `spec/spec_helper.rb`.
10+
11+
Edit `bin/knapsack_pro` to use your API token.
12+
13+
Run RSpec tests with Knapsack Pro:
1014

1115
```
12-
rspec
16+
bin/knapsack_pro
1317
```
1418

15-
The RSpec before(:suite) hook is called.
16-
17-
Expected output:
19+
The expected output:
1820

1921
```
2022
RSpec before(:suite) hook called.
2123
.........
2224
23-
Finished in 0.00998 seconds (files took 0.51173 seconds to load)
25+
Finished in 0.42772 seconds (files took 0.19781 seconds to load)
2426
9 examples, 0 failures
2527
```
2628

29+
The RSpec `before(:suite)` hook is called.

bin/knapsack_pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
export KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=be5ca096c07e995a8800ee0ce1b1ec7c
4+
export KNAPSACK_PRO_LOG_LEVEL=warn
5+
6+
# detect branch and commit hash with git
7+
export KNAPSACK_PRO_REPOSITORY_ADAPTER=git
8+
export KNAPSACK_PRO_PROJECT_DIR=.
9+
# or, you can define them on your own (please ensure you comment out the above two env vars)
10+
#export KNAPSACK_PRO_COMMIT_HASH=commit-hash
11+
#export KNAPSACK_PRO_BRANCH=branch
12+
13+
export KNAPSACK_PRO_CI_NODE_BUILD_ID=$(openssl rand -base64 32)
14+
export KNAPSACK_PRO_CI_NODE_TOTAL=1
15+
export KNAPSACK_PRO_CI_NODE_INDEX=0
16+
17+
bundle exec rake "knapsack_pro:queue:rspec[--format progress]"

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
require 'knapsack_pro'
2+
3+
# Custom Knapsack Pro config here
4+
5+
KnapsackPro::Adapters::RSpecAdapter.bind
6+
17
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
28
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
39
# The generated `.rspec` file contains `--require spec_helper` which will cause

0 commit comments

Comments
 (0)