Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

### 1.17.0

* Add `KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX` to allow run Cucumber with spring gem in Queue Mode

https://github.com/KnapsackPro/knapsack_pro-ruby/pull/98

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.16.1...v1.17.0

### 1.16.1

* Allow to use Queue Mode for old RSpec versions that don't have `RSpec.configuration.reset_filters` method
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ bundle exec rake knapsack_pro:queue:rspec
bundle exec rake knapsack_pro:queue:minitest

# Cucumber
# If you use spring gem and spring-commands-cucumber gem to start Cucumber tests faster please set
# export KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX=bundle exec spring
# or you can use spring binstub
# export KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX=bin/spring
# Thanks to that Cucumber will start tests faster for each batch of tests fetched from Knapsack Pro Queue API
bundle exec rake knapsack_pro:queue:cucumber
```

Expand Down
4 changes: 4 additions & 0 deletions lib/knapsack_pro/config/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ def fixed_queue_split
ENV.fetch('KNAPSACK_PRO_FIXED_QUEUE_SPLIT', false)
end

def cucumber_queue_prefix
ENV.fetch('KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX', 'bundle exec')
end

def test_suite_token
env_name = 'KNAPSACK_PRO_TEST_SUITE_TOKEN'
ENV[env_name] || raise("Missing environment variable #{env_name}. You should set environment variable like #{env_name}_RSPEC (note there is suffix _RSPEC at the end). knapsack_pro gem will set #{env_name} based on #{env_name}_RSPEC value. If you use other test runner than RSpec then use proper suffix.")
Expand Down
5 changes: 4 additions & 1 deletion lib/knapsack_pro/runners/queue/cucumber_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def self.run_tests(accumulator)
def self.cucumber_run(runner, test_file_paths, args)
stringify_test_file_paths = KnapsackPro::TestFilePresenter.stringify_paths(test_file_paths)

cmd = %Q[bundle exec cucumber #{args} --require #{runner.test_dir} -- #{stringify_test_file_paths}]
cmd = [
KnapsackPro::Config::Env.cucumber_queue_prefix,
%Q[cucumber #{args} --require #{runner.test_dir} -- #{stringify_test_file_paths}]
].join(' ')

Kernel.system(cmd)

Expand Down
14 changes: 14 additions & 0 deletions spec/knapsack_pro/config/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,20 @@
end
end

describe '.cucumber_queue_prefix' do
subject { described_class.cucumber_queue_prefix }

context 'when ENV exists' do
before { stub_const("ENV", { 'KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX' => 'bundle exec spring' }) }
it { should eq 'bundle exec spring' }
end

context "when ENV doesn't exist" do
before { stub_const("ENV", {}) }
it { should eq 'bundle exec' }
end
end

describe '.test_suite_token' do
subject { described_class.test_suite_token }

Expand Down