我想通过使用 Mini_Test 和 Ruby 来实现 DCI,但我无法在 Mini_Test 中调用 AcademicYear 类。我在单独的文件中有一个简单的类和 Mini_Test 类,如下所示;
/app/Models/academicyear.rb
class AcademicYear
attr_accessor :year
end
/app/Test/Contexts/headteacher_define_academicyear_context_test.rb
require "minitest_helper"
class HeadTeacherDefineAcademicYearContextTest < MiniTest::Unit::TestCase
def test_should_add_academic_year
academicyear = AcademicYear.new
academicyear.year= "2012-2013"
end
end
当我创建一个新的 AcademicYear 对象时,出现此错误;
HeadTeacherDefineAcademicYearContextTest#test_should_add_academic_year:
NameError: uninitialized constant HeadTeacherDefineAcademicYearContextTest::AcademicYear
/home/developer/Desktop/dciexample/test/contexts/headteacher_define_academicyear_context_test.rb:6:in `test_should_add_academic_year'
我错过了什么,有什么想法吗?