spec/blobby/http_store_spec.rb in blobby-1.0.1 vs spec/blobby/http_store_spec.rb in blobby-1.1.0

- old
+ new

@@ -1,5 +1,7 @@ +require "spec_helper" + require "ostruct" require "blobby/http_store" require "blobby/in_memory_store" require "blobby/store_behaviour" require "sinatra/base" @@ -39,13 +41,11 @@ settings.backing_store end def key params[:captures].first.tap do |key| - if key =~ /FAIL/ # simulate failure - fail "hell" - end + fail "hell" if key =~ /FAIL/ # simulate failure end end end @@ -100,21 +100,21 @@ describe "#read" do it "raises an exception" do expect do subject[key].read - end.to raise_error + end.to raise_error("hell") end end describe "#write" do it "raises an exception" do expect do subject[key].write("something") - end.to raise_error + end.to raise_error("hell") end end end @@ -177,11 +177,11 @@ it { is_expected.not_to be_available } end - context "when the base_url does not include a trailing slash" do + context "when the base_uri does not include a trailing slash" do subject do described_class.new("http://#{http_storage_host}/prefix") end @@ -189,18 +189,23 @@ expect(subject.base_uri.to_s).to eq("http://#{http_storage_host}/prefix/") end end - context "when the base_url does include a trailing slash" do + context "when the base_uri does include a trailing slash" do subject do described_class.new("http://#{http_storage_host}/prefix/") end it "does not append another" do expect(subject.base_uri.to_s).to eq("http://#{http_storage_host}/prefix/") end + end + + it "can be created with a URI" do + store = described_class.new(URI("http://#{http_storage_host}/prefix/")) + expect(store.base_uri.to_s).to eq("http://#{http_storage_host}/prefix/") end end