Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test that a block cannot be passed to test-level it and specify

  • Loading branch information...
commit 27dacbd8c61027572d2b957a34bf327dbeadf961 1 parent 1b2dd27
Ryan Carver authored
Showing with 14 additions and 2 deletions.
  1. +2 −2 lib/minitest/spec.rb
  2. +12 −0 test/test_minitest_spec.rb
4 lib/minitest/spec.rb
View
@@ -259,7 +259,7 @@ class << self
# will be prefixed with 'it '.
def it msg
- raise "A block must not be passed to the example-level +it+" if block_given?
+ raise ArgumentError, "A block must NOT be passed to the example-level `it`" if block_given?
@__current_msg = "it #{msg}"
end
@@ -269,7 +269,7 @@ def it msg
# will be used verbatim.
def specify msg
- raise "A block must not be passed to the example-level +specify+" if block_given?
+ raise ArgumentError, "A block must NOT be passed to the example-level `specify`" if block_given?
@__current_msg = msg
end
12 test/test_minitest_spec.rb
View
@@ -533,6 +533,18 @@ def assert_triggered expected = "blah", klass = MiniTest::Assertion
1.must_equal 2
end
end
+
+ it "enforces that you do not use a block form for assertion messages set via 'it' or 'specify'" do
+ @assertion_count = 2
+
+ assert_raises(ArgumentError) do
+ it "uses this" do end
+ end
+
+ assert_raises(ArgumentError) do
+ specify "this is used" do end
+ end
+ end
end
describe MiniTest::Spec, :let do
Please sign in to comment.
Something went wrong with that request. Please try again.