Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Base Directories

DuckTest uses a root directory when looking for all files. By default, DuckTest::Config will use Rails.root as it's own root directory. In an attempt to help keep config files from being complicated and messy, DuckTest employs a base directory for runnable and non-runnable files.

  • runnable_basedir is a base directory that should be located directly off of the {DuckTest::ConfigHelper#root root} directory and is automagically factored in when searching for files that are runnable.

  • watch_basedir is a base that should be located directly off of the {DuckTest::ConfigHelper#root root} directory and is automagically factored in when searching for files that are non-runnable.

The main reason for the existence of the base directories is to help ease the pain of configuration by eliminating the need to include directory names in filter and mapping expressions.

For example:

  DuckTest.config do
    runnable "test**/*"
    watch "app**/*" do
      map /app/models/, /^book.rb/ do
        target /^test/unit/, /^book/
        target /^test/unit/, /^special_case/
      end
      map /app/models/, /^car.rb/ do
        target /^test/unit/, /^car/
        target /^test/unit/, /^special_case/
      end
    end
  end

  DuckTest.config do
    runnable_basedir :test
    watch_basedir :app
    runnable "**/*"
    watch "**/*" do
      map /models/, /^book.rb/ do
        target /^unit/, /^book/
        target /^unit/, /^special_case/
      end
      map /models/, /^car.rb/ do
        target /^unit/, /^car/
        target /^unit/, /^special_case/
      end
    end
  end

runnablebasedir and watchbasedir attributes trickle down into all of runnable, watch, map blocks, however, you do have the option of overriding for a specific block by passing a value to the block. For example, let's say that you want to watch some of the files in the app lib directory. You could do that in a couple of ways.

  DuckTest.config do
    runnable_basedir :test
    watch_basedir :app
    runnable "**/*"
    watch "**/*", basedir: :lib do  # setting it by passing an argument
      map /models/, /^book.rb/ do
        target /^unit/, /^book/
        target /^unit/, /^special_case/
      end
    end
  end

or

  DuckTest.config do
    runnable_basedir :test
    watch_basedir :app
    runnable "**/*"
    watch "**/*" do
      watch_basedir :lib            # setting it within the block
      map /models/, /^book.rb/ do
        target /^unit/, /^book/
        target /^unit/, /^special_case/
      end
    end
  end

or

  DuckTest.config do
    runnable_basedir :test
    watch_basedir :app
    runnable "**/*"
    watch "**/*"

    framework :rspec do
      runnable_basedir :rspec     # setting it within a framework definition
      runnable "**/*"
      watch "**/*"
    end
  end

The base directories are intended to reduce the clutter in large config files with a lot of mappings.