Sha256: b285e617aacd8cab3ad0507604a5cf631f303073f138ca655777c87e858cfb4b

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

class Spec < Thor
  def initialize
    gem "rspec"
    require "spec/autorun"
  end

  desc "rango [path]", "Run Rango specs"
  def rango(path = "spec")
    spec(path, "--options", "spec/spec.opts")
  end

  desc "stubs", "Create stubs of all library files."
  def stubs
    Dir.glob("lib/**/*.rb").each do |file|
      specfile = file.sub(/^lib/, "spec").sub(/\.rb$/, '_spec.rb')
      unless File.exist?(specfile)
        %x[mkdir -p #{File.dirname(specfile)}]
        %x[touch #{specfile}]
        puts "Created #{specfile}"
      end
    end
    (Dir.glob("spec/rango/**/*.rb") + ["spec/rango_spec.rb"]).each do |file|
      libfile = file.sub(/spec/, "lib").sub(/_spec\.rb$/, '.rb')
      if !File.exist?(libfile) && File.zero?(file)
        %x[rm #{file}]
        puts "Removed empty file #{file}"
      elsif !File.exist?(libfile)
        puts "File exists just in spec, not in lib: #{file}"
      end
    end
  end

  protected
  def spec(*argv)
    ARGV.clear
    ARGV.push(*argv)
    ::Spec::Runner::CommandLine.run
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rango-0.0.6 tasks/spec.thor
rango-0.1.pre tasks/spec.thor