Sha256: c579abeb59cac6bba34633310ba5927a2e87c9e040ca66869043c55bbf564d6e

Contents?: true

Size: 742 Bytes

Versions: 9

Compression:

Stored size: 742 Bytes

Contents

require "rake"

module RakeHelpers
  def invoke_rake_task(name, args = [])
    RakeTask.new(name).invoke(*args)
  end
end

class RakeTask
  def initialize(name)
    @task_name = name
    prep_environment
  end

  delegate :invoke, to: :task

  private

  attr_reader :task_name

  def prep_environment
    Rake.application = rake
    Rake.load_rakefile(full_task_path)
    Rake::Task.define_task(:environment)
  end

  def full_task_path
    "#{root_path}/lib/tasks/#{task_name.split(':').first}.rake"
  end

  def root_path
    File.expand_path('../..', __dir__)
  end

  def task
    rake[task_name]
  end

  def rake
    @_rake ||= Rake::Application.new
  end
end

RSpec.configure do |config|
  config.include RakeHelpers, type: :rake
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
hubspot-api-ruby-0.9.0 spec/support/rake.rb
hubspot-api-ruby-0.8.1 spec/support/rake.rb
hubspot-ruby-0.9.0 spec/support/rake.rb
hubspot-api-ruby-0.8.0 spec/support/rake.rb
hubspot-ruby-0.8.1 spec/support/rake.rb
hubspot-ruby-0.8.0 spec/support/rake.rb
hubspot-ruby-0.7.0 spec/support/rake.rb
hubspot-ruby-0.6.1 spec/support/rake.rb
hubspot-ruby-0.6.0 spec/support/rake.rb