Commit 06386b3
Changed files (3)
spec
spec/unit/container_spec.rb
@@ -1,5 +1,3 @@
-require "spec_helper"
-
module Spank
describe Container do
subject { Container.new }
spec/unit/ioc_spec.rb
@@ -1,5 +1,3 @@
-require "spec_helper"
-
describe Spank::IOC do
after :each do
Spank::IOC.unbind
@@ -10,14 +8,12 @@ describe Spank::IOC do
let(:component) { double }
before :each do
- allow(container).to receive(:resolve).with(:idbconnection).and_return(component)
+ allow(container).to receive(:resolve).with(:dbconnection).and_return(component)
Spank::IOC.bind_to(container)
end
- let(:result) { Spank::IOC.resolve(:idbconnection) }
-
it "resolves the item from the container" do
- expect(result).to eq(component)
+ expect(Spank::IOC.resolve(:dbconnection)).to eq(component)
end
end
spec/unit/proxy_spec.rb
@@ -1,14 +1,12 @@
-require "spec_helper"
-
module Spank
describe Proxy do
- let(:sut) { Proxy.new(target) }
+ subject { Proxy.new(target) }
let(:target) { double("target", :greet => nil) }
context "when invoking a method" do
- before { sut.greet('blah') }
+ before { subject.greet('blah') }
- it "should send the message to the target" do
+ it "sends the message to the target" do
expect(target).to have_received(:greet).with('blah')
end
end
@@ -18,16 +16,16 @@ module Spank
let(:interceptor) { double('interceptor', :intercept => "") }
before :each do
- sut.add_interceptor(:greet, interceptor)
- sut.greet("blah")
+ subject.add_interceptor(:greet, interceptor)
+ subject.greet("blah")
end
- it "should allow the interceptor to intercept the call" do
+ it "allows the interceptor to intercept the call" do
expect(interceptor).to have_received(:intercept)
end
end
context "when invoking a method with a block" do
- it "should pass the block to the target" do
+ it "passes the block to the target" do
proxy = Proxy.new([])
expect do
proxy.each do |x|
@@ -39,7 +37,7 @@ module Spank
end
context "when invoking a method that is not defined on the target" do
- it "should raise an error" do
+ it "raises an error" do
expect { Proxy.new("blah").goodbye }.to raise_error
end
end