spec/riak/client_spec.rb in riak-client-0.8.2 vs spec/riak/client_spec.rb in riak-client-0.8.3
- old
+ new
@@ -142,19 +142,25 @@
describe "choosing an HTTP backend" do
before :each do
@client = Riak::Client.new
end
- it "should choose the Curb backend if Curb is available" do
- @client.should_receive(:require).with('curb').and_return(true)
- @client.http.should be_instance_of(Riak::Client::CurbBackend)
+ it "should choose the selected backend" do
+ @client.http_backend = :NetHTTP
+ @client.http.should be_instance_of(Riak::Client::NetHTTPBackend)
+
+ unless defined? JRUBY_VERSION
+ @client = Riak::Client.new
+ @client.http_backend = :Curb
+ @client.http.should be_instance_of(Riak::Client::CurbBackend)
+ end
end
- it "should choose the Net::HTTP backend if Curb is unavailable" do
- @client.should_receive(:require).with('curb').and_raise(LoadError)
- @client.should_receive(:warn).and_return(true)
- @client.http.should be_instance_of(Riak::Client::NetHTTPBackend)
+ it "should raise an error when the chosen backend is not valid" do
+ Riak::Client::NetHTTPBackend.should_receive(:configured?).and_return(false)
+ @client = Riak::Client.new(:http_backend => :NetHTTP)
+ lambda { @client.http }.should raise_error
end
end
describe "retrieving a bucket" do
before :each do
@@ -231,16 +237,16 @@
@http = mock(Riak::Client::HTTPBackend)
@client.stub!(:http).and_return(@http)
@http.should_receive(:delete).with([204,404], "/luwak", "greeting.txt")
@client.delete_file("greeting.txt")
end
-
+
it "should return true if the file exists" do
@client = Riak::Client.new
@client.http.should_receive(:head).and_return(:code => 200)
@client.file_exists?("foo").should be_true
end
-
+
it "should return false if the file doesn't exist" do
@client = Riak::Client.new
@client.http.should_receive(:head).and_return(:code => 404)
@client.file_exists?("foo").should be_false
end