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.6.31 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.30 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.29 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.28 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.27 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.26 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.25 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.24 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.23 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.22 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.21 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.20 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.19 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.18 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.17 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.16 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.15 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.14 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.13 tracks/ruby/lib/tasks/exercise_tests_runner.rb
trackler-2.0.6.12 tracks/ruby/lib/tasks/exercise_tests_runner.rb