main
 1require "spec_helper"
 2
 3describe "using" do
 4  let(:item) { double("item", dispose: true) }
 5
 6  it "disposes the item" do
 7    using(item) { }
 8    item.should have_received(:dispose)
 9  end
10
11  it "performs the action" do
12    ran = false
13    using(item) do
14      ran = true
15    end
16    ran.should be_true
17  end
18
19  it "always cleans up the resource" do
20    begin
21      using(item) { raise "heck" }
22    rescue
23    end
24    item.should have_received(:dispose)
25  end
26end