Sha256: 31e67b5ccf0f80f7a5fe3323a1f3198f0a4fddfc0a272948ca10eac58e987c3f

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require './test/test_helper'

class AssignmentTest < Minitest::Test

  def project_dir
    '/tmp'
  end

  def teardown
    FileUtils.rm_rf File.join(project_dir, 'ruby')
  end

  def readme_path
    File.join(project_dir, 'ruby', 'queens', 'README.md')
  end

  def tests_dir
    File.join(project_dir, 'ruby', 'queens')
  end

  def tests_path
    File.join(tests_dir, 'queens_test.rb')
  end

  def assignment_data
    {
      'track' => 'ruby',
      'slug' => 'queens',
      'readme' => 'Do it',
      'test_file' => 'queens_test.rb',
      'tests' => 'assert true',
      'project_dir' => project_dir
    }
  end

  def test_write_assignment_from_project_directory
    assignment = Exercism::Assignment.new(assignment_data)
    assignment.save

    assert_equal "Do it", File.read(readme_path)
    assert_equal "assert true", File.read(tests_path)
  end

  def test_do_not_overwrite_existing_test_file
    FileUtils.mkdir_p(tests_dir)
    FileUtils.touch(tests_path)
    File.open(tests_path, 'w') do |file|
      file.write 'assert false'
    end

    Exercism::Assignment.new(assignment_data).save

    assert_equal "assert false", File.read(tests_path)
  end

  def test_save_and_return_assignments
    data = { 'assignments' => [ assignment_data ] }
    saved = Exercism::Assignment.save(data, project_dir)

    assert_equal 1, saved.size
    assert_equal assignment_data['slug'], saved.first.slug
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
exercism-0.0.28 test/exercism/assignment_test.rb
exercism-0.0.27 test/exercism/assignment_test.rb
exercism-0.0.26 test/exercism/assignment_test.rb
exercism-0.0.25 test/exercism/assignment_test.rb
exercism-0.0.24 test/exercism/assignment_test.rb
exercism-0.0.23 test/exercism/assignment_test.rb
exercism-0.0.22 test/exercism/assignment_test.rb
exercism-0.0.21 test/exercism/assignment_test.rb
exercism-0.0.20 test/exercism/assignment_test.rb
exercism-0.0.19 test/exercism/assignment_test.rb
exercism-0.0.18 test/exercism/assignment_test.rb
exercism-0.0.17 test/exercism/assignment_test.rb
exercism-0.0.16 test/exercism/assignment_test.rb
exercism-0.0.15 test/exercism/assignment_test.rb
exercism-0.0.14 test/exercism/assignment_test.rb
exercism-0.0.13 test/exercism/assignment_test.rb