Sha256: 4d475cf5d2c9ccb144cf1cc9fd95cb603e02a7087fb33db55996dca92c81ad01

Contents?: true

Size: 1.33 KB

Versions: 187

Compression:

Stored size: 1.33 KB

Contents

require_relative '../test_helper'
require 'tmpdir'

class ExerciseTest < Minitest::Test
  def test_all
    Dir.mktmpdir('exercise-test') do |dir|
      FileUtils.mkdir "#{dir}/test"
      FileUtils.mkdir "#{dir}/test2"
      FileUtils.touch "#{dir}/TRACK_HINTS.md"

      FileList.stub :[], FileList["#{dir}/*"] do
        assert_equal true, Exercise.all.all? { |e| e.instance_of?(Exercise) }
        assert_equal ['test', 'test2'], Exercise.all.map(&:slug)
      end
    end
  end

  def test_slug
    exercise = Exercise.new('slug')
    assert_equal 'slug', exercise.slug
  end

  def test_to_s
    exercise = Exercise.new('slug')
    assert_equal 'slug', exercise.to_s
  end

  def test_directory
    exercise = Exercise.new('slug')
    assert_equal 'exercises/slug/.', exercise.directory
  end

  def test_example_file
    mock_exist = Minitest::Mock.new
    mock_exist.expect(:call, true, ['exercises/alpha/./.meta/solutions/alpha.rb'])
    File.stub(:exist?, mock_exist) do
      assert_equal '.meta/solutions/alpha.rb', Exercise.new('alpha').example_file
    end
  end

  def test_testable_example_file
    exercise = Exercise.new('all-your-base')
    assert_equal 'all_your_base.rb', exercise.testable_example_file
  end

  def test_test_file
    exercise = Exercise.new('all-your-base')
    assert_equal 'all_your_base_test.rb', exercise.test_file
  end
end

Version data entries

187 entries across 187 versions & 1 rubygems

Version Path
trackler-2.2.1.137 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.136 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.135 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.134 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.133 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.132 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.131 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.130 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.129 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.128 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.127 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.126 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.125 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.124 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.123 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.122 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.121 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.120 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.119 tracks/ruby/test/tasks/exercise_test.rb
trackler-2.2.1.118 tracks/ruby/test/tasks/exercise_test.rb