Open FilBot3 opened 6 years ago
From playing around with this a bit and looking at the spec's and the Thorfile included with the repository, you need to create a Thor task to invoke the Rake task.
require 'thor/rake_compat'
require 'rspec/core/rake_task'
class Default < Thor
include Thor::RakeCompat
RSpec::Core::RakeTask.new(:spec) do |t|
t.spec_opts = ['--options', './.rspec']
t.spec_files = FileList['spec/**/*_spec.rb']
end
desc 'spec', 'Run RSpec tests'
def spec
Rake::Task['spec'].invoke
end
end
Even taking from the rake_compat_spec.rb
require 'thor/rake_compat'
require "rake/tasklib"
class RakeTask < Rake::TaskLib
def initialize
define
end
def define
instance_eval do
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
end
class ThorTask < Thor
include Thor::RakeCompat
RakeTask.new
desc 'cool', 'say cool'
def cool
Rake::Task['cool'].invoke
puts ThorTask.tasks['cool'].description
end
end
The result is:
thor thor_task:cool
COOL
say cool
Would it be helpful to make this into a Wiki page as well?
Using the example found here: https://www.rubydoc.info/github/wycats/thor/Thor/RakeCompat
I am unable to run the RSpec task, or have it show when running
thor list
.