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.159 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.158 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.157 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.156 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.155 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.154 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.153 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.152 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.151 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.150 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.149 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.148 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.147 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.146 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.145 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.144 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.143 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.142 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.141 tracks/ruby/test/tasks/exercise_test_tasks_test.rb
trackler-2.2.1.140 tracks/ruby/test/tasks/exercise_test_tasks_test.rb