Method: Test::Unit::TestCase.test
- Defined in:
- lib/tu-context/test.rb
.test(name, opts = {}, &block) ⇒ Object
Create a test method. name is a native-language string to describe the test (e.g., no more test_this_crazy_thing_with_underscores).
test "A user should not be able to delete another user" do
assert_false @user.can?(:delete, @other_user)
end
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tu-context/test.rb', line 10 def test(name, opts={}, &block) test_name = ["test:", context_name, name].reject { |n| n == "" }.join(' ') # puts "running test #{test_name}" defined = instance_method(test_name) rescue false raise "#{test_name} is already defined in #{self}" if defined unless opts[:before].nil? before_should_callbacks[test_name] = opts[:before] end if block_given? define_method(test_name, &block) else define_method(test_name) do flunk "No implementation provided for #{name}" end end end |