Sha256: 7862fd54f256e68132f1ec06c19184f21876cb927be17c6c1381bf644bc2d5b6
Contents?: true
Size: 1012 Bytes
Versions: 6
Compression:
Stored size: 1012 Bytes
Contents
require 'test_helper' class ProcTest < ActiveSupport::TestCase def return_block(lambda = nil, &block) return block || lambda end test "#source returns a proc's source" do block = return_block { |f| do_something } assert_equal "{ |f|\n do_something\n }", block.source end test "#source works with a do block" do block = return_block do |f| do_something end assert_equal "do |f|\n do_something\n end", block.source end test "#source works with a single line block" do block = return_block { whatever } assert_equal '{ whatever }', block.source end test "#source works with a block containing a block" do block = return_block { whatever { another } } assert_equal '{ whatever { another } }', block.source end # TODO: make work (with arguments) # test "#source works with a stabby lambda" do # block = return_block -> (something) { whatever } # assert_equal '-> { whatever }', block.source # end end
Version data entries
6 entries across 6 versions & 1 rubygems