Sha256: d37a17ffd7652ca4a109c7ec1af507cff5088a93aa4fb804bbc656d552bbaa4a

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe Object do
  it 'should respond to the new methods' do
    Object.new.should respond_to(*%w(try tap))
  end

  it 'should return itself from tap' do
    a = Object.new
    a.tap { |s| }.should equal(a)
  end

  it 'should return nil from try if called on nil' do
    nil.try(1) { |a| }.should be_nil
  end

  it 'should try...like really try' do
    nil.try { |me| me.foo }.should be_nil
    true.try { |me| me }.should be_true
    true.try(:nil?).should_not be_nil
  end

  it 'should tap dance' do
    10.tap { |m| m.should == 10 }.should == 10
    o = Object.new
    o.tap { |m| m.should == o }.should == o
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
darkhelmet-darkext-0.12.0 spec/object_spec.rb
darkext-0.12.0 spec/object_spec.rb