Sha256: 21bb28c3a404677559745936ab8d994f7e024ddc3c82c08917427ae642a9f727

Contents?: true

Size: 1.34 KB

Versions: 42

Compression:

Stored size: 1.34 KB

Contents

require_relative '../test_helper'
require 'tasks/exercise'
require 'tasks/exercise_test_tasks'

class ExerciseTestTasksTest < Minitest::Test
  def test_all_exercises_task
    setup_rake

    Exercise.stub :all, ['test1', 'test2'] do
      ExerciseTestTasks.new(options: '')

      assert_equal ['test1', 'test2'], Rake::Task['exercises'].prerequisites
      assert_equal 'Run the tests for all exercises', Rake::Task['exercises'].comment
    end
  end

  def test_individual_exercise_tasks
    setup_rake

    Exercise.stub :all, ['test1', 'test2'] do
      mock_test_runner_instance = Minitest::Mock.new
      mock_test_runner_instance.expect :run, nil
      mock_test_runner_instance.expect :run, nil

      mock_test_runner = Minitest::Mock.new
      mock_test_runner.expect(
        :new,
        mock_test_runner_instance,
        [exercise: 'test1', test_options: '-p'],
      )
      mock_test_runner.expect(
        :new,
        mock_test_runner_instance,
        [exercise: 'test2', test_options: '-p'],
      )

      ExerciseTestTasks.new(options: '-p', test_runner: mock_test_runner)

      Rake::Task['test1'].invoke
      Rake::Task['test2'].invoke

      mock_test_runner.verify
      mock_test_runner_instance.verify
    end
  end

  def setup_rake
    Rake.application = Rake::Application.new
    Rake::TaskManager.record_task_metadata = true
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.179 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.178 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.177 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.176 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.175 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.174 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.173 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.172 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.171 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.170 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.169 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.167 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.166 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.165 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.164 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.163 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.162 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.161 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.160 tracks/ruby/test/tasks/exercise_test_tasks_test.rb