Module: JakeWendt::TestWithVerbosity::ClassMethods

Defined in:
lib/test_with_verbosity.rb

Instance Method Summary collapse

Instance Method Details

#test(name, &block) ⇒ Object

activesupport-4.1.4/lib/active_support/testing/declarative.rb my modified version



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/test_with_verbosity.rb', line 19

def test(name, &block)
	#test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
	test_name = "test_#{name.gsub(/\W/,'_')}".to_sym					#	NEED THIS
	defined = instance_method(test_name) rescue false
	raise "#{test_name} is already defined in #{self}" if defined
	if block_given?
#				define_method(test_name, &block)

#
#	could possibly do something like this, but I can't seem to figure out
#	how to call a passed block correctly.
#
#	lots of the like ....
#	NoMethodError: undefined method `assert' for InterviewAssignmentTest:Class
#
		define_method(test_name) do
			print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
			#	block.call	#	FAIL
			#	self.block.call	#	FAIL
			#	yield	#	FAIL
			instance_exec(&block)		#	SUCCESS!
		end
	else
		define_method(test_name) do
			flunk "No implementation provided for #{name}"
		end
	end
end