spec/unit/proxy_spec.rb in spank-0.0.1393558686 vs spec/unit/proxy_spec.rb in spank-1.0.1420314444
- old
+ new
@@ -1,35 +1,33 @@
-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
- target.should have_received(:greet).with('blah')
+ it "sends the message to the target" do
+ expect(target).to have_received(:greet).with("blah")
end
end
context "when an interceptor is registered" do
context "when invoking a method" do
- let(:interceptor) { double('interceptor', :intercept => "") }
+ 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
- interceptor.should have_received(:intercept)
+ 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|
raise StandardError
end
@@ -37,10 +35,10 @@
end
end
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
end
end