tracks/ruby/test/generator/template_values_test.rb in trackler-2.1.0.1 vs tracks/ruby/test/generator/template_values_test.rb in trackler-2.1.0.2

- old
+ new

@@ -41,19 +41,60 @@ mock_canonical_data.expect :abbreviated_commit_hash, nil mock_canonical_data.expect :to_s, '{"cases":[]}' mock_canonical_data end + def paths + mock_paths = Minitest::Mock.new + mock_paths.expect :track, 'test/fixtures/xruby' + mock_paths + end + include TemplateValuesFactory end - def test_template_values - $LOAD_PATH.unshift 'test/fixtures/xruby/lib' + class ClassBasedTestTemplateValuesFactory + def exercise_name + 'beta' + end + + def version + 2 + end + + def canonical_data + mock_canonical_data = Minitest::Mock.new + mock_canonical_data.expect :abbreviated_commit_hash, nil + mock_canonical_data.expect :to_s, '{"cases":[]}' + mock_canonical_data + end + + def paths + mock_paths = Minitest::Mock.new + mock_paths.expect :track, 'test/fixtures/xruby' + mock_paths + end + + include TemplateValuesFactory + end + + def test_template_values_from_class + subject = ClassBasedTestTemplateValuesFactory.new + assert_instance_of TemplateValues, subject.template_values + end + + def test_template_values_loads_problem_case_classes subject = TestTemplateValuesFactory.new assert_instance_of TemplateValues, subject.template_values + assert Object.const_defined?(:AlphaCase) + assert Object.const_defined?(:AlphaCases) end def teardown - $LOAD_PATH.delete 'test/fixtures/xruby/lib' + [:AlphaCase, :AlphaCases].each do |classname| + if Object.const_defined?(classname) + Object.send(:remove_const, classname) + end + end end end end