Sha256: 26cdea1141d735cc2c8b7d30e5cf6830b7e3539ba78d3c8ea083ada3ea044b06

Contents?: true

Size: 735 Bytes

Versions: 20

Compression:

Stored size: 735 Bytes

Contents

# From: https://robots.thoughtbot.com/test-rake-tasks-like-a-boss
require 'rake'

shared_context 'rake_task' do
  let(:rake)      { Rake::Application.new }
  let(:task_name) { self.class.top_level_description }
  let(:task_path) { "lib/tasks/#{task_name.split(':')[0,2].join('_')}" }
  # let(:task_path) { "lib/tasks/#{task_name.split(":").first}" }
  subject         { rake[task_name] }

  def loaded_files_excluding_current_rake_file
    $".reject {|file| file == Rails.root.join("../../#{task_path}.rake").to_s }
  end

  before do
    Rake.application = rake
    Rake.application.rake_require(task_path, [Rails.root.join('../..').to_s], loaded_files_excluding_current_rake_file)

    Rake::Task.define_task(:environment)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mno-enterprise-core-3.4.0 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.3.3 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.3.2 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.2.1 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.3.1 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.3.0 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.2.0 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.1.4 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.7 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.1.3 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.6 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.1.2 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.5 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.1.1 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.4 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.1.0 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.3 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.2 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.1 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb
mno-enterprise-core-3.0.0 lib/mno_enterprise/testing_support/shared_contexts/rake_task.rb