Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 93911249d1
Fetching contributors…

Cannot retrieve contributors at this time

50 lines (40 sloc) 1.115 kB
require "spec_helper"
require "objectify/instantiator"
describe "Objectify::Instantiator" do
module My
class Service
end
end
class MyPolicy
end
before do
@injector = stub("Injector")
@instantiator = Objectify::Instantiator.new(@injector)
end
context "with a service" do
before do
@service = My::Service.new
@injector.stubs(:call).returns(@service)
@result = @instantiator.call(:my, :service)
end
it "returns the result of injector#call" do
@result.should == @service
end
it "locates the service in the supplied namespace and instantiates" do
@injector.should have_received(:call).with(My::Service, :new)
end
end
context "with a policy" do
before do
@policy = MyPolicy.new
@injector.stubs(:call).returns(@policy)
@result = @instantiator.call(:my, :policy)
end
it "returns the result of injector#call" do
@result.should == @policy
end
it "locates the policy namespace and instantiates" do
@injector.should have_received(:call).with(MyPolicy, :new)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.