Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use to_proc on named blocks

  • Loading branch information...
commit fdef77b13332e1ed1f10ae474def03b040a1e45a 1 parent 85a5c02
@svenfuchs authored
Showing with 7 additions and 3 deletions.
  1. +3 −3 lib/with/group.rb
  2. +4 −0 lib/with/named_block.rb
View
6 lib/with/group.rb
@@ -43,9 +43,9 @@ def define_test_method(target, context)
method_name = generate_test_method_name(context)
target.send :define_method, method_name, &lambda {
- preconditions.map { |precondition| instance_eval &precondition.block }
- instance_eval &action.block
- assertions.map { |assertion| instance_eval &assertion.block }
+ preconditions.map { |precondition| instance_eval &precondition }
+ instance_eval &action
+ assertions.map { |assertion| instance_eval &assertion }
}
end
View
4 lib/with/named_block.rb
@@ -6,6 +6,10 @@ def initialize(name, &block)
@name = name
@block = block or raise "need to provide a block for an assertion"
end
+
+ def to_proc
+ @block
+ end
def call
@block.call
Please sign in to comment.
Something went wrong with that request. Please try again.