Sha256: a3ecd1daa233b9c87e07ac9d1df3150f3261d636ca1c7d7a563a99d8aa76c5e9

Contents?: true

Size: 1.52 KB

Versions: 97

Compression:

Stored size: 1.52 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"].should include(Rake.application.rakefile)
  end

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

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

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

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

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

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

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

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

Version data entries

97 entries across 92 versions & 11 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.7.5 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.7.4 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.7.3 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/thor-0.14.6/spec/rake_compat_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/thor-0.14.6/spec/rake_compat_spec.rb
wijet-thor-0.14.10 spec/rake_compat_spec.rb
classiccms-0.7.2 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.7.1 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.7.0 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
wijet-thor-0.14.9 spec/rake_compat_spec.rb
classiccms-0.6.9 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.8 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.7 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.6 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.5 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.4 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.3 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.2 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb
classiccms-0.6.1 vendor/bundle/gems/thor-0.14.6/spec/rake_compat_spec.rb