Sha256: 508e84580910c3f77c53b157d4289c7f1b93bb959aeeed7a12116ebb2eaa99c4

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

require 'sugar-high/delegate'

class Actor
  def act
    'actor'
  end
end

class Context
  delegate :act, :to => :actor

  def actor
    Actor.new
  end
end

describe 'delegate NOT already defined' do
  specify { Context.new.act.should == 'actor' }
end

class SuperRange < DelegateDecorator
  attr_accessor :range

  def initialize range
    super(range, except: ['to_s', 'to_str'])
    @range = range
  end

  def to_s
    "Super: #{range}"
  end

  def to_str
    to_s
  end
end

describe DelegateDecorator do
  subject { SuperRange.new (0..2) }

  specify {
    subject.to_s.should == "Super: 0..2"
    subject.to_str.should == "Super: 0..2"
  }

  specify { subject.min.should == subject.range.min }
  specify { subject.max.should == subject.range.max }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sugar-high-0.7.3 spec/sugar-high/delegate_spec.rb