Class: KnapsackPro::Runners::RSpecRunner

Inherits:
BaseRunner
  • Object
show all
Defined in:
lib/knapsack_pro/runners/rspec_runner.rb

Class Method Summary collapse

Methods inherited from BaseRunner

#initialize, #stringify_test_file_paths, #test_dir, #test_file_paths, #test_files_to_execute_exist?

Constructor Details

This class inherits a constructor from KnapsackPro::Runners::BaseRunner

Class Method Details

.run(args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/knapsack_pro/runners/rspec_runner.rb', line 4

def self.run(args)
  ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_rspec
  ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true'

  runner = new(KnapsackPro::Adapters::RSpecAdapter)

  if runner.test_files_to_execute_exist?
    require 'rspec/core/rake_task'

    task_name = 'knapsack_pro:rspec_run'
    if Rake::Task.task_defined?(task_name)
      Rake::Task[task_name].clear
    end

    RSpec::Core::RakeTask.new(task_name) do |t|
      t.rspec_opts = "#{args} --default-path #{runner.test_dir}"
      t.pattern = runner.test_file_paths
    end
    Rake::Task[task_name].invoke
  end
end