Ruby test harness for running Target Practice (.tp) tests
Latest commit 5853acf Apr 7, 2012 @kellysutton kellysutton Updating the README
Failed to load latest commit information.
lib Pulling the JSON parsing into TargetPractice Apr 7, 2012
.gitignore ignore the generated gems Apr 6, 2012
Gemfile derpy doo Apr 6, 2012 Updating the README Apr 7, 2012
Rakefile this maybe? Apr 6, 2012
target_practice.gemspec derpy doo Apr 6, 2012

Target Practice

A Ruby library for running Target Practice (.tp) test bundles.


Put the following in your Gemfile

gem 'target_practice'


Writing TargetPractice tests.

TargetPractice tests work by comparing a JSON file to an object that you specify. This allows you to write simple that are language agnostic. Nifty.

Let's take a look at a hypothetical example, parsing a PSD.

In my Rakefile:

require 'rubygems'
require 'rake/testtask'
require 'test/psdtest' do |test|
  test.pattern = "test/**/*.json"
  test.test_class = PSDTest

And a simple test case test/

  "_title": "CMYK Header",
  "_file": "fixtures/test-cmyk8.psd",
  "psd": {
    "height": 1

And my PSD test harness:

TP_ROOT = 'test/'

class PSDTest < TargetPracticeTestCase
  def tests_against_files
    @@files.each do |file|
      @@current_file = file

  def do_file_test(test_data)
    puts "Starting test for #{test_data['_file']}"
    assert test_data["_file"], "Input file was not provided!"
    psd = PSD.from_file(TP_ROOT + test_data["_file"])

    assert_attributes(psd, test_data["psd"])

A little wordy, but this will ensure that if a PSD-parsing module existed, when parsing the file defined in the JSON, it should have the height attribute equal to 1. If not, it fails.


TargetPractice was developed by Kelly Sutton for LayerVault.