Low commit activity in last 3 years
A long-lived project that still receives updates
Split Rails logs across RSpec examples
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3

Runtime

>= 7.1, < 8
 Project Readme

SplitRailsLogs Build Status

Splits rails logs into separate files for each RSpec example, allowing much easier debugging without having to sift through one file containing everything.

Mostly intended for CI environments, where it can be valuable to capture Rails logs for test failures and upload them as build artifacts for later inspection.

Usage

Add to Gemfile

gem 'split_rails_logs'

Require it:

require "split_rails_logs"

And add to your RSpec configuration:

RSpec.configure do |config|
  config.around do |example|
    SplitRailsLogs.for_failed(example)
  end
end

for_failed will only write out logs for examples that have failed. If you want split logs for everything, you can instead use for_any:

SplitRailsLogs.for_any(example)

You'll now end up with a separate Rails log per example:

log
├── spec
│   └── events
│       └── user
│           ├── locked_spec.rb:12.test.log
│           ├── locked_spec.rb:25.test.log
│           └── unlocked_spec.rb:33.test.log

If you're using something like buildkite, configure it to upload all artifacts that match the appropriate pattern, for example:

- label: "Unit specs"
  command: "bin/ci-unit"
  artifact_paths: ["log/spec/**/*.test.log"]

Various other CI platforms will have similar configurations available.

Developing

Stick with semver. Keep the tests green 🙂

bundle exec rspec

License

MIT