Permalink
Browse files

add before_should, before_test, before_tests, etc

Signed-off-by: Jeremy McAnally <jeremymcanally@gmail.com>
  • Loading branch information...
jamesgolick authored and jm committed Jan 19, 2009
1 parent dee4d69 commit b94a0edd2791387b033fe38c9963d2237209ff6e
Showing with 23 additions and 0 deletions.
  1. +6 −0 lib/context/test.rb
  2. +11 −0 test/test_lifecycle.rb
  3. +6 −0 test/test_test.rb
View
@@ -27,5 +27,11 @@ def test(name, opts={}, &block)
end
%w(it should tests).each {|m| alias_method m, :test}
+
+ def before_test(name, &block)
+ test(name, :before => block) {}
+ end
+
+ %w(before_it before_should before_tests).each {|m| alias_method m, :before_test}
end
end
View
@@ -177,4 +177,15 @@ class TestLifecycle < Test::Unit::TestCase
assert_equal "override success!", @jvar
end
end
+
+ context "Before tests" do
+ # omg this is odd
+ setup do
+ assert_equal "yup, it's set", @ivar
+ end
+
+ before_test "run before the setup block" do
+ @ivar = "yup, it's set"
+ end
+ end
end
View
@@ -6,6 +6,12 @@ def test_test_aliases
assert self.class.respond_to?(method_alias)
end
end
+
+ def test_before_test_aliases
+ [:before_test, :before_it, :before_should, :before_tests].each do |method_alias|
+ assert self.class.respond_to?(method_alias), method_alias.inspect
+ end
+ end
context "A test block" do
it "should create a test_xxx method" do

0 comments on commit b94a0ed

Please sign in to comment.