test/defined_test.rb in defined-0.0.0 vs test/defined_test.rb in defined-0.0.1

- old
+ new

@@ -1,6 +1,6 @@ -require 'test_helper' +require File.expand_path('../test_helper', __FILE__) class DefinedTest < Test::Unit::TestCase module TestMethods attr_reader :file, :line, :method, :called @@ -95,20 +95,22 @@ assert Mock.called end def test_should_call_defined_when_module_is_defined_with_new mod = Module.new { extend TestMethods } - assert mod.called + assert mod.called, 'Mock.defined was not called after calling Module.new' assert_equal :initialize, mod.method end %w(class instance module).each do |prefix| %w(eval exec).each do |suffix| method_name = [prefix, suffix].join('_').to_sym - define_method "test_should_call_defined_when_module_is_defined_with_#{method_name}" do - Mock.send(method_name) { @called = false } - assert Mock.called - assert_equal method_name, Mock.method + if respond_to?(method_name) + define_method "test_should_call_defined_when_module_is_defined_with_#{method_name}" do + Mock.send(method_name) { @called = false } + assert Mock.called, "Mock.defined was not called after calling #{method_name}" + assert_equal method_name, Mock.method + end end end end protected \ No newline at end of file