Sha256: 835ff179130adaa52f36c571b7f1afc3ae870c43b09a28fe8f27f563f65b1d94

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby
# encoding: utf-8

ENV['RACK_ENV'] ||= 'test'

if ARGV.empty?
  puts "usage: cutest [-r lib] [-v] file [-b (backtrace) [-p (pry rescue)]]"
  exit
end

require "clap"
require_relative "../lib/cutest"

files = Clap.run ARGV,
  "-r"      => lambda { |file| require file },
  "-t"      => lambda { |name| cutest[:only] = name },
  "-s"      => lambda { |name| cutest[:scope] = name },
  "-a"      => lambda { cutest[:all_tests] = true },
  "-w"      => lambda { |name| cutest[:warnings] = true },
  "-b"      => lambda { cutest[:backtrace] = true },
  "-p"      => lambda {
    ENV['PRY_RESCUE'] = 'true'; cutest[:pry_rescue] = true
  },
  "-d"      => lambda {
    require 'pry'
    require 'awesome_print'
    ENV['PRY_RESCUE']   = 'true'
    cutest[:pry_rescue] = true
  },
  "-v"      => lambda { puts Cutest::VERSION }

if files.any?
  begin
    env      = '.env'
    rack_env = "#{env}.#{ENV['RACK_ENV']}"

    if File.file? rack_env
      Cutest.load_envs rack_env
    elsif File.file? env
      Cutest.load_envs env
    end

    success = Cutest.run(Dir[*files])

    exit(1) unless success
  rescue ThreadError
    # Ignore this as it's caused by Process.waitall when using -p
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cutest-cj-1.6.2 bin/cutest
cutest-cj-1.6.1 bin/cutest
cutest-cj-1.6.0 bin/cutest