Sha256: 631657ffbdbf3586884853db3e026ce3d315bf65a5a307fbdda9847645304f34

Contents?: true

Size: 1.51 KB

Versions: 25

Compression:

Stored size: 1.51 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'thor/rake_compat'
require 'rake/tasklib'

class RakeTask < Rake::TaskLib
  def initialize
    define
  end
  
  def define
    desc "Say it's cool"
    task :cool do
      puts "COOL"
    end

    namespace :hiper_mega do
      task :super do
        puts "HIPER MEGA SUPER"
      end
    end
  end
end

class ThorTask < Thor
  include Thor::RakeCompat
  RakeTask.new
end

describe Thor::RakeCompat do
  it "sets the rakefile application" do
    ["rake_compat_spec.rb", "Thorfile"].must include(Rake.application.rakefile)
  end

  it "adds rake tasks to thor classes too" do
    task = ThorTask.tasks["cool"]
    task.must be
  end

  it "uses rake tasks descriptions on thor" do
    ThorTask.tasks["cool"].description.must == "Say it's cool"
  end

  it "gets usage from rake tasks name" do
    ThorTask.tasks["cool"].usage.must == "cool"
  end

  it "uses non namespaced name as description if non is available" do
    ThorTask::HiperMega.tasks["super"].description.must == "super"
  end

  it "converts namespaces to classes" do
    ThorTask.const_get(:HiperMega).must == ThorTask::HiperMega
  end

  it "does not add tasks from higher namespaces in lowers namespaces" do
    ThorTask.tasks["super"].must_not be
  end

  it "invoking the thor task invokes the rake task" do
    capture(:stdout) do
      ThorTask.start ["cool"]
    end.must == "COOL\n"

    capture(:stdout) do
      ThorTask::HiperMega.start ["super"]
    end.must == "HIPER MEGA SUPER\n"
  end
end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
puppet-module-0.3.4 vendor/thor-852190ae/spec/rake_compat_spec.rb
puppet-module-0.3.3 vendor/thor-852190ae/spec/rake_compat_spec.rb
puppet-module-0.3.2 vendor/thor-852190ae/spec/rake_compat_spec.rb
thor-0.14.4 spec/rake_compat_spec.rb
thor-0.14.3 spec/rake_compat_spec.rb
thor-0.14.2 spec/rake_compat_spec.rb
thor-0.14.1 spec/rake_compat_spec.rb
angry_mob-0.1.0 vendor/thor/spec/rake_compat_spec.rb
thor-0.14.0 spec/rake_compat_spec.rb
thor-0.13.8 spec/rake_compat_spec.rb
thor-0.13.7 spec/rake_compat_spec.rb
puppet-module-0.3.0 vendor/thor-852190ae/spec/rake_compat_spec.rb
thor-0.13.6 spec/rake_compat_spec.rb
thor-0.13.5 spec/rake_compat_spec.rb
thor-0.13.4 spec/rake_compat_spec.rb
thor-0.13.3 spec/rake_compat_spec.rb
thor-0.13.2 spec/rake_compat_spec.rb
thor-0.13.1 spec/rake_compat_spec.rb
thor-0.13.0 spec/rake_compat_spec.rb
thor-0.12.3 spec/rake_compat_spec.rb