Continuous Integration is really the soul of one's modern development workflows. Test suites become bottlenecks when Ruby and Rails projects scale up. FastCI is a thin gem granting the power of parallelization to streamline your RSpec runs with minimal fuss.
In this tutorial, we'll be doing a quick, fancy 3-step merging of FastCI into your project. You don't need to switch from the platform you are using; this will only help you speed up the process.
Adding Your Environment Variable
Every FastCI setup begins with an important client token. That token helps FastCI to authenticate your project and keep your builds secure.
Add the following line to your shell configuration (e.g., .bashrc, .zshrc, or your CI environment variables):
export FAST_CI_SECRET_KEY=6bd25b8c2e1a
Replace your-client-token-here with the token you will find in your FastCI dashboard. After that, reload your shell or restart your terminal to have the variable live.
Adding FastCI to Your Gemfile
Open your project’s Gemfile and add the FastCI gem:
gem "fast_ci"
Then install it by running:
bundle install
And that’s all for this step. FastCI is now available in your Ruby environment.
Configuring RSpec with FastCI
If using RSpec in the project, you will need to hook FastCI into your test runner. Open spec_helper.rb (or rails_helper.rb if you configure RSpec there) and place the following snippet at the very beginning:
if ENV["FAST_CI_SECRET_KEY"]
require "fast_ci"
require "rspec/core/runner"
require "fast_ci/runner_prepend"
class RSpec::Core::ExampleGroup
def self.filtered_examples
ids = Thread.current[:fastci_scoped_ids] || ""
RSpec.world.filtered_examples[self].filter do |ex|
ids == "" || /^#{ids}($|,)/.match?(ex.metadata[:scoped_id])
end
end
end
RSpec::Core::Runner.prepend(FastCI::RunnerPrepend)
end
This snippet tells RSpec to respect FastCI’s test scoping, so only the right subset of tests runs per job.
Conclusion
It only takes a few minutes to set up FastCI, but the benefits are enormous. Your team will receive faster feedback loops, spend less time waiting, and be able to concentrate on writing excellent code rather than observing progress bars if you reduce RSpec run times.
Your CI pipeline becomes leaner, faster, and more developer-friendly with just three simple steps: adding your token, installing the gem, and updating your RSpec configuration.