Permalink
Browse files

With the parent context's setup being frozen each time anyway, there …

…is no point worrying about the static_setup vs setup issues. No reason to expand the API more than needed.
  • Loading branch information...
1 parent 6c5dc8b commit 27137d75d0ddb430c28ccd766f4696812fa453fa @tomlea committed Apr 30, 2009
Showing with 3 additions and 13 deletions.
  1. +2 −3 lib/shoulda/context.rb
  2. +0 −5 lib/shoulda/static_context.rb
  3. +1 −5 test/other/context_test.rb
View
@@ -174,8 +174,7 @@ def context(name, &blk)
# == Static Contexts
# A static context works much like a normal context. Appart from a few key differences:
#
- # * It has a #static_setup instead of a #setup method.
- # * Its static setup is only called once, no matter how many test cases, and sub contexts it contains.
+ # * Its static context's setup is only called once, no matter how many test cases, and sub contexts it contains.
# * Instance variables are shared for each method inside the context (so be careful not to change those variables inside assertions).
# * No matter how many shoulds are inside the static context, parent setups are only called once.
# * Instance variables set in the setup blocks of parent scopes are also shared.
@@ -188,7 +187,7 @@ def context(name, &blk)
#
# class UserTest < Test::Unit::TestCase
# static_context "A User instance" do
- # static_setup do
+ # setup do
# @user = User.find(:first)
# @user.some_expensive_operation!
# end
@@ -1,7 +1,6 @@
module Shoulda
class StaticContext < Context # :nodoc:
MAGIC_TEST_CASE_INSTANCE_VARIABLES = %w{@method_name @loaded_fixtures @fixture_cache @_result @test_passed}
- undef_method :setup
undef_method :teardown
attr_accessor :post_setup_instance_variables
@@ -10,10 +9,6 @@ def setup_already_run?
!post_setup_instance_variables.nil?
end
- def static_setup(&blk)
- self.setup_blocks << blk
- end
-
def run_all_setup_blocks(binding)
if setup_already_run?
post_setup_instance_variables.each do |name, value|
@@ -171,14 +171,10 @@ def hello; "hi"; end
should "not allow us to setup a should(.., :before) hook, as that would be silly" do
assert_raise(ArgumentError) { @context.should("foo", :before => proc{}){} }
end
-
- should "not allow us to declare a setup, because that does not make it obvious as to what it is doing" do
- assert !@context.respond_to?(:setup)
- end
end
static_context "static context with setup and teardown only run once" do
- static_setup do
+ setup do
@@static_setup_var ||= 0
@@static_setup_var += 1
@instance_var ||= 0

0 comments on commit 27137d7

Please sign in to comment.