rubytestingrakeredgreen

Can I run our tests using redgreen without changing our source code?


I'd like to use redgreen (or similar) to colour the output of our tests, but I don't want to force it on everyone else. Is there a way for me to use it without changing our source code?


Solution

  • You can add code like this to your test_helper.rb to base it on your environment settings:

    if ENV['REDGREEN']
      require 'redgreen'
    end
    

    If the project uses bundler, you'll need it in the Gemfile, but you can disable it by default:

    gem "redgreen", :require => false
    

    You can have redgreen always enabled in your own personal environment by adding it to ~/.bashrc or ~/.zshrc or the appropriate file for your shell:

    export REDGREEN=true