Example of Ruby on Rails app with knapsack gem. Knapsack is a free gem, see https://github.com/ArturT/knapsack
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Remove .ruby-version Mar 3, 2018
app Add cucumber tests with scenario outline examples May 3, 2015
bin rails app:update Aug 5, 2016
config Add represent_boolean_as_integer to fix minitest Mar 3, 2018
db
features
lib Add cucumber and generate fresh setup May 3, 2015
log
public Generate RailsAppWithKnapsack project May 1, 2015
script Add cucumber and generate fresh setup May 3, 2015
spec
spinach_features Add example files in dir with spaces Mar 22, 2017
test Merge master into rails5 and fix conflict Mar 3, 2018
vendor/assets Generate RailsAppWithKnapsack project May 1, 2015
.gitignore Ignore .DS_Store Aug 18, 2017
.rspec Add rspec and a few specs with shared examples May 3, 2015
Gemfile Update to Rails 5.2.1 Sep 20, 2018
Gemfile.lock knapsack (1.17.1) Dec 4, 2018
LICENSE Initial commit May 1, 2015
README.md Update readme circle links Mar 27, 2018
Rakefile Load knapsack tasks May 1, 2015
config.ru Generate RailsAppWithKnapsack project May 1, 2015
knapsack_cucumber_report.json Add knapsack for cucumber May 3, 2015
knapsack_minitest_report.json Add info about override test with minitest syntax May 1, 2015
knapsack_rspec_report.json Run rspec test suite in parallel with knapsack May 3, 2015
knapsack_spinach_report.json Add spinach features Jun 3, 2016

README.md

Rails app with knapsack

Circle CI

This is example Ruby on Rails app with knapsack gem. Knapsack splits tests across CI nodes and makes sure that tests will run comparable time on each node.

You can read more about free knapsack gem here. You will find there info how to set up your test suite and how to do it on your favorite CI server.

How to load knapsack rake tasks

See Rakefile.

Parallel rspec test suite with knapsack

How to set up knapsack

See spec/spec_helper.rb

Step 1

First generate only once a report knapsack_rspec_report.json on your CI with command:

$ KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec

Add the report into your repository and commit.

Step 2

You can use below command on CI to run tests:

# Run this on first CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:rspec

# Run this on second CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=1 bundle exec rake knapsack:rspec

See .circleci/config.yml to see how we set up CircleCI.

Parallel cucumber test suite with knapsack

How to set up knapsack

See features/support/knapsack.rb

Step 1

First generate only once a report knapsack_cucumber_report.json on your CI with command:

$ KNAPSACK_GENERATE_REPORT=true bundle exec cucumber features

Add the report into your repository and commit.

Step 2

You can use below command on CI to run tests:

# Run this on first CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:cucumber

# Run this on second CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=1 bundle exec rake knapsack:cucumber

See .circleci/config.yml to see how we set up CircleCI.

Parallel minitest test suite with knapsack

How to set up knapsack

See test/test_helper.rb

Step 1

First generate only once a report knapsack_minitest_report.json on your CI with command:

$ KNAPSACK_GENERATE_REPORT=true bundle exec rake test

Add the report into your repository and commit.

Step 2

You can use below command on CI to run tests:

# Run this on first CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:minitest

# Run this on second CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=1 bundle exec rake knapsack:minitest

See .circleci/config.yml to see how we set up CircleCI.

Parallel spinach test suite with knapsack

How to set up knapsack

See spinach_features/support/env.rb

Step 1

First generate only once a report knapsack_spinach_report.json on your CI with command:

$ KNAPSACK_GENERATE_REPORT=true bundle exec spinach -f spinach_features

Add the report into your repository and commit.

Step 2

You can use below command on CI to run tests:

# Run this on first CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 KNAPSACK_TEST_FILE_PATTERN="spinach_features/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_features]"

# Run this on second CI server
$ CI_NODE_TOTAL=2 CI_NODE_INDEX=1 KNAPSACK_TEST_FILE_PATTERN="spinach_features/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_features]"

See .circleci/config.yml to see how we set up CircleCI.