#!/usr/bin/env ruby
require "pathname"
require "fileutils"
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path("..", __dir__)

def system!(*args)
  system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
  # This script runs test and open up code coverage

  puts "\n== Running the test =="
  spec_path = ARGV[0] || "spec"
  system "bin/rspec #{spec_path}"

  puts "\n== Opening Simplecov =="
  system! "open coverage/index.html"
end
