Sha256: ab21579ce239d0774ddc946f98eb5a18070692e5705bb24e0795ac8faca07de1

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

require 'rake/testtask'
require 'tmpdir'

Dir.chdir(File.dirname(__FILE__) + '/..')

Rake::TestTask.new do |t|
  examples_tests_dir = Dir.mktmpdir('iw_examples')

  FileUtils::cp_r(Dir.glob('examples/*'), examples_tests_dir)

  Dir.glob('examples/**/**.rb').each do |path|
    next unless path =~ %r|examples/(.*)/([^/]+)/\2.rb$|

    dir = $1
    name = $2

    test_path = examples_tests_dir + "/#{dir}/#{name}/test_example_#{name}.rb"

    File.open(test_path, 'w') do |out|
      out << "require 'helpers'\n"
      out << "class #{name.capitalize}Test < Test::Unit::TestCase\n"
      out << "def test_example\n"

      File.readlines(path).each do |line|
        line, assert_str = line.chomp.split /#>/
        out << line << "\n"

        if assert_str
          cond, desc = assert_str.split /--/
          out << "assert(" << cond << ", '" <<
            (desc or "").gsub(/'/, "\\\\'") << "')\n"
        end
      end

      out << "end\nend\n"
    end
  end

  t.libs << "lib" << "test" << examples_tests_dir
  files = FileList['test/**/**.rb',
                   examples_tests_dir + '/**/test_*.rb']
  t.test_files = files.keep_if{ |f| f =~ Regexp.new(ENV['TESTP'] || '') }

  t.verbose = true
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iron_worker_ng-0.3.3 test/Rakefile
iron_worker_ng-0.3.2 test/Rakefile
iron_worker_ng-0.3.1 test/Rakefile
iron_worker_ng-0.3.0 test/Rakefile
iron_worker_ng-0.2.7 test/Rakefile
iron_worker_ng-0.2.6 test/Rakefile
iron_worker_ng-0.2.5 test/Rakefile
iron_worker_ng-0.2.4 test/Rakefile
iron_worker_ng-0.2.3 test/Rakefile