require File.join(File.dirname(__FILE__), 'ptk_helper') require 'active_test/subject' class ActiveTest::TestSubject < ActiveTest::Subject class << self def reflects(action, options = {}) define_behavioral(:reflect, action, options) { true } end end end class SubjectBehavioralsTest < ActiveTest::TestSubject def setup @subject = self.class end def test_should_define_test_method_from_behaviour_class_method assert_method_defined(@subject, :test_should_reflect_index) do @subject.class_eval { reflects :index } end end def test_should_define_unique_test_methods assert_method_defined(@subject, :test_should_reflect_show) do @subject.class_eval { reflects :show } end assert_method_defined(@subject, :test_should_reflect_show_variant_2) do @subject.class_eval { reflects :show } end end protected def assert_method_defined(klass, method) assert !klass.method_defined?(method), "Definition already exists" yield assert klass.method_defined?(method), "Definition not created" end end