Sha256: 1adc23eb6ee0b67eeb2e9fd260b83a4454f6dfdb31f35efdf85719d73acd3433
Contents?: true
Size: 2 KB
Versions: 4
Compression:
Stored size: 2 KB
Contents
require File.dirname(__FILE__) + '/persistable_helper.rb' describe CouchObject::Persistable, "setting the storage location:" do before(:each) do @bike = Bike.new @db = "http://localhost:5984/mydb" @with_location = WithStorageLocation.new @db = "http://localhost:5984/mydb" content = HTTPResponse.new(JSON.unparse({ "_id" => "123BAC", "_rev" => "946B7D1C", })) CouchObject::Response.stub!(:body).and_return(content) @empty_response = {} @ok_response = {"ok" => true} @document_response = CouchObject::Response.new(content) end it "the storage location should be blank if not set at class level" do @bike.location.should == nil @bike.storage_location.should == nil end it "should be possible to change the storage location for instances" do location = @bike.location @bike.set_location = "foo" @bike.location.should_not == location location = @bike.storage_location @bike.set_storage_location = "bar" @bike.storage_location.should_not == location end it "setting the storage location to a blank string should make it nil" do @bike.set_location = "foo" @bike.set_location = "" @bike.location.should == nil @bike.set_storage_location = "foo" @bike.set_storage_location = "" @bike.location.should == nil end it "setting the location using one of the getters should raise an error" do lambda{ @bike.location = "" }.should raise_error(NoMethodError) lambda{ @bike.storage_location = "" }.should raise_error(NoMethodError) end it "classes with the storage location should have a location by default" do @with_location.location.should == @db end it "classes with the storage location set by default should be able to change it" do @with_location.set_location = "foo" @with_location.location.should == "foo" end it "a base class should know it's storage location if it has been set by default" do WithStorageLocation::location.should == @db end end
Version data entries
4 entries across 2 versions & 1 rubygems