Sha256: 01c2775dcc9ed000c686f410dfd810cb1249b0f067ccc065ef116a768314c7b7

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

require 'spec_helper'

RSpec.describe LazyObject do

  class TargetObject
    attr_accessor :value

    def method_with_yield(foo)
      yield foo
    end
  end

  let(:lazy_object) {
    LazyObject.new do
      targ = TargetObject.new
      targ.value = :foo
      targ
    end
  }

  it 'should call the init block and forward methods to the target object' do
    expect( lazy_object.value ).to eq(:foo)
    lazy_object.value = :bar
    expect( lazy_object.value ).to eq(:bar)

    expect( lazy_object.method_with_yield(:baz) { |foo| "--#{foo}--" } ).to eq('--baz--')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lazy_object-0.0.2 spec/lazy_object_spec.rb