Sha256: a4c5467f8b7063228248c634feee9feb125426a4c3767ac5cbe5e3fbe4c0c45b

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..',  'test_helper.rb'))

class TestCaseTest < Test::Unit::TestCase
  
  def setup
    @test_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_cases', 'test1.rb'))
  end
  
  test "should load test case" do
    test_case = AnySpec::TestCase.new(@test_file, "ruby")
    assert_equal test_case.test_code, 'print "this is a test"'
    assert_equal test_case.assertion_code, 'assert_output "this is a test"'
    assert_equal "ruby", test_case.target_executable
    assert_equal @test_file, test_case.path
  end
  
  test "should run test case" do
    test_case = AnySpec::TestCase.new(@test_file, "ruby")
    result = test_case.run
    assert_equal true, result
  end
  
  test "test case that is not formatted correctly should raise exception" do
    assert_raises Exception do
      @test_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_cases', 'incorrect.blah'))
      test_case = AnySpec::TestCase.new(@test_file, "ruby")
    end
  end
  
  test "empty test case should raise exception" do
    assert_raises Exception do
      @test_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_cases', 'empty.blah'))
      test_case = AnySpec::TestCase.new(@test_file, "ruby")
    end
  end
  
  test "test case that does not exist should raise exception" do
    assert_raises Exception do
      @test_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_cases', 'does_not_exist.blah'))
      test_case = AnySpec::TestCase.new(@test_file, "ruby")
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
any-spec-0.1.0 test/unit/test_case_test.rb
any-spec-0.0.1 test/unit/test_case_test.rb
any-spec-0.0.0 test/unit/test_case_test.rb