Sha256: 5efa28fb31461e2c85fb96f3469147e5446b38e6a002fdd717b145b61c51fb7a

Contents?: true

Size: 856 Bytes

Versions: 5

Compression:

Stored size: 856 Bytes

Contents

require "spec_helper"

module Nasty
  describe Lazy do
    context "when lazy loading an item from a factory" do
      context "when invoking a method on the proxy" do
        let(:factory) { double }
        let(:blackbook) { double }

        before :each do
          blackbook.stub(:find).and_return("nasty")
          Lazy.bind_factory do |key|
            blackbook if key == :blackbook
          end
        end

        it "should invoke the target" do
          Lazy.load(:blackbook).find(:booty).should == "nasty"
        end
      end

      context "before invocation" do
        let(:factory) { ->(*args) { @called = true } }

        before :each do
          Lazy.load(:blackbook, factory)
        end

        it "does not resolve the component from the factory" do
          @called.should be_false
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nasty-0.0.1395464273 spec/unit/lazy_spec.rb
nasty-0.0.1388168019 spec/unit/lazy_spec.rb
nasty-0.0.1388167257 spec/unit/lazy_spec.rb
nasty-0.0.1388166944 spec/unit/lazy_spec.rb
nasty-0.0.1388166636 spec/unit/lazy_spec.rb