1. Skip to navigation
  2. Skip to content

The ELC Community Blog

A knowledge exchange on Ruby on Rails and Agile Development


Reconciling TextMate With redgreen Tests

by ceberz on August 22, 2007

Many of us use Pat Eyler's redgreen gem for increased readability and aesthetic during our testing. Unfortunately for TextMate users like myself who enjoy using the program's support for invoking tests from within the editor, the redgreen gem conflicts with the editors already decorated output:

TextMate has a modest plethora (if you'll pardon the oxymoron) of environment variables that you can poll to see if the test is running in the scope of the editor. A conditional require in test_helper.rb...

require 'redgreen' if ENV['TM_FILENAME'].nil?

...will prevent the gem from being included when running your tests within TextMate. Tests invoked from the console will, of course, be decorated by the gem as usual.

Comments

Ziemek at 12:27 PM on May 14 2008

Awesome Thanks!

Btw, If you freeze the gem using gemsonrails you will need to edit the Init.rb slight to make it work. This is because the gem gets included automatically.

Just rap the code with the if statement. Here is how my init.rb looks like:

if ENV[‘TM_FILENAME’].nil? require_options = [“redgreen”] if require_lib = require_options.find { |path| File.directory?(File.join(File.dirname(FILE), ‘lib’, path)) } require File.join(File.dirname(FILE), ‘lib’, require_lib) else puts msg = “ERROR: Please update #{File.expand_path FILE} with the require path for linked RubyGem redgreen” exit end end

Add a comment


home | services | Ruby on Rails Development | code | blog | company