Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated `context` to display a warning message if the context block i…

…s missing

Closes https://github.com/thoughtbot/shoulda/issues/#issue/18

Signed-off-by: Ryan McGeary <ryanongit@mcgeary.org>
  • Loading branch information...
commit 3224df5f920a98061627474c27b3caaa8ca0aabd 1 parent ddb7d57
@matflores matflores authored rmm5t committed
Showing with 14 additions and 1 deletion.
  1. +5 −1 lib/shoulda/context/context.rb
  2. +9 −0 test/shoulda/should_test.rb
View
6 lib/shoulda/context/context.rb
@@ -302,7 +302,11 @@ def initialize(name, parent, &blk)
self.should_eventuallys = []
self.subcontexts = []
- merge_block(&blk)
+ if block_given?
+ merge_block(&blk)
+ else
+ merge_block { warn " * WARNING: Block missing for context '#{full_name}'" }
+ end
Shoulda::Context.remove_context
end
View
9 test/shoulda/should_test.rb
@@ -128,6 +128,15 @@ def test_should_create_a_new_context
end
end
+ def test_should_create_a_new_context_even_if_block_is_omitted
+ old_verbose, $VERBOSE = $VERBOSE, nil
+ assert_nothing_raised do
+ Shoulda::Context::Context.new("context without a block", self)
+ end
+ ensure
+ $VERBOSE = old_verbose
+ end
+
def test_should_create_a_nested_context
assert_nothing_raised do
parent = Shoulda::Context::Context.new("Parent", self) do; end
Please sign in to comment.
Something went wrong with that request. Please try again.