Sha256: d5bae3e9191825b3c5bb18370976e37caf2708a82a7ae1ebe891f35ef2124f8e

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

require 'spec_helper'

describe Dependor::Isolate do
  class ExampleSubject
    takes :foo, :bar
  end

  class ExampleContext
    include Dependor::Isolate

    def subject
      isolate(ExampleSubject)
    end

    def override
      isolate(ExampleSubject, bar: "bar was overriden")
    end

    def foo
      "the foo stub"
    end

    def bar
      "the bar stub"
    end
  end

  it "injects the subject's dependencies using methods on context" do
    context = ExampleContext.new

    context.subject.foo.should == "the foo stub"
    context.subject.bar.should == "the bar stub"
  end

  it "allows overriding dependencies" do
    context = ExampleContext.new

    context.override.bar.should == "bar was overriden"
    context.override.foo.should == "the foo stub"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dependor-0.0.5 spec/dependor/isolate_spec.rb