Sha256: dec4e88ddbd03c185958c9f143e390cbe94e9b3b2bb603e4ccdda6f250895e23

Contents?: true

Size: 732 Bytes

Versions: 101

Compression:

Stored size: 732 Bytes

Contents

require 'rake/file_utils_ext'
require 'tmpdir'

class ExerciseTestsRunner
  include Rake::FileUtilsExt

  def initialize(exercise:, test_options: '')
    @exercise = exercise
    @test_options = test_options
  end

  def run
    puts "\n\n#{'-' * 64}\nrunning tests for: #{@exercise}"

    Dir.mktmpdir(@exercise.name) do |dir|
      setup_exercise_files_in(dir)
      run_exercise_tests_in(dir)
    end
  end

  private

  def setup_exercise_files_in(dir)
    FileUtils.cp_r @exercise.directory, dir
    FileUtils.mv "#{dir}/#{@exercise.example_file}", "#{dir}/#{@exercise.testable_example_file}"
  end

  def run_exercise_tests_in(dir)
    ruby "-I lib -r disable_skip.rb #{dir}/#{@exercise.test_file} #{@test_options}"
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
trackler-2.0.8.6 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.8.5 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.8.4 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.8.3 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.8.2 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.8.1 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.7.0 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.44 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.43 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.42 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.41 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.40 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.39 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.38 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.37 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.36 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.35 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.34 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.33 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.32 tracks/ruby/lib/tasks/exercise_tests_runner.rb