Tuesday, March 15, 2011

bacon and autotest

Took a little to figure this out, so thought I would share.  You need an empty file in your spec folder called .bacon in your spec folder.  This appears to load up a lot of the proper bacon environment things into autotest.  However, if you want to override specific behaviors, you do that in a .autotest file in the top directory.

touch spec/.bacon

Inside .autotest:
require 'rubygems'
require 'bacon'
require 'autotest/bacon'

# see inside /lib/autotest/bacon.rb for template

class Autotest::Bacon < Autotest
  undef make_test_cmd
  def make_test_cmd(files_to_test)
    # I modified this to only include _spec.rb files:
    args = files_to_test.keys.flatten.select {|v| v =~ /_spec.rb$/ }.join(' ')
    args = '-a' if args.empty?
    # TODO : make regex to pass to -n using values
    # use bacon -h to see all your possible options!
    "#{ruby} -S bacon -I#{libs} -o TestUnit #{args}"

No comments: