Sha256: a77d8bb72e0ecbd4dbe7e68479375b73f7066e7b93d2c9bcaec7d1b1599fc418

Contents?: true

Size: 760 Bytes

Versions: 13

Compression:

Stored size: 760 Bytes

Contents

module BlockGivenSpecs
  def self.is_block_given
    block_given?
  end

  def self.calls_block_given_with_block(&x)
    is_block_given(&x)
  end
end

describe "Kernel#block_given?" do
  it "can be used outside of a method scope" do
    block_given?
  end
  
  it "can check if a block was given" do
    BlockGivenSpecs.is_block_given.should == false
    BlockGivenSpecs.is_block_given {}.should == true
  end
  
  it "works with explicitly passed blocks" do
    BlockGivenSpecs.calls_block_given_with_block.should == false
    BlockGivenSpecs.calls_block_given_with_block {}.should == true
  end
  
  it "works with #to_proc'd blocks" do
    BlockGivenSpecs.is_block_given(&nil).should == false
    BlockGivenSpecs.is_block_given(&:x).should == true
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
opal-0.3.40 spec/core/kernel/block_given.rb
opal-0.3.39 spec/core/kernel/block_given.rb
opal-0.3.38 spec/core/kernel/block_given.rb
opal-0.3.37 spec/core/kernel/block_given.rb
opal-0.3.36 spec/core/kernel/block_given.rb
opal-0.3.35 spec/core/kernel/block_given.rb
opal-0.3.34 spec/core/kernel/block_given.rb
opal-0.3.33 spec/core/kernel/block_given.rb
opal-0.3.32 spec/core/kernel/block_given.rb
opal-0.3.31 spec/core/kernel/block_given.rb
opal-0.3.30 spec/core/kernel/block_given.rb
opal-0.3.29 spec/core/kernel/block_given.rb
opal-0.3.28 spec/core/kernel/block_given.rb