Sha256: b19b603d8f951d045764fd9f02952075d4b90bc98113362ed72cd4e7ccc431a9

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require './test/test_helper'

class AssignmentTest < MiniTest::Unit::TestCase

  def setup
    @project_dir = FileUtils.pwd
  end

  def teardown
    FileUtils.cd @project_dir
    FileUtils.rm_rf File.join(@project_dir, 'test/fixtures/ruby')
  end

  def readme_path
    File.join(@project_dir, 'test/fixtures/ruby/queens/README.md')
  end

  def tests_path
    File.join(@project_dir, 'test/fixtures/ruby/queens/test.rb')
  end

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

  def test_write_assignment_from_project_directory
    FileUtils.cd 'test/fixtures'
    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_write_assignment_from_language_directory
    FileUtils.mkdir File.join(@project_dir, 'test/fixtures/ruby')
    FileUtils.cd 'test/fixtures/ruby'
    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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exercism-0.0.3 test/exercism/assignment_test.rb
exercism-0.0.2 test/exercism/assignment_test.rb