Modified:
trunk/VERSION
trunk/lib/active_couch/base.rb
trunk/spec/base/marshal_dump_spec.rb
trunk/spec/base/marshal_load_spec.rb
trunk/spec/base/save_spec.rb
Log:
- Removing zlibing while marshalling. This needs to be delegated to the
application level
- More specs to verify whether update works
- Version 0.1.2 it is
Modified: trunk/VERSION
==============================================================================
--- trunk/VERSION (original)
+++ trunk/VERSION Tue Apr 8 02:20:34 2008
@@ -1 +1 @@
-0.1.1
\ No newline at end of file
+0.1.2
\ No newline at end of file
Modified: trunk/lib/active_couch/base.rb
==============================================================================
--- trunk/lib/active_couch/base.rb (original)
+++ trunk/lib/active_couch/base.rb Tue Apr 8 02:20:34 2008
@@ -162,13 +162,13 @@
def marshal_dump # :nodoc:
# Deflate using Zlib
- Zlib::Deflate.deflate(self.to_json)
+ self.to_json
end
def marshal_load(str) # :nodoc:
self.instance_eval do
# Inflate first, and then parse the JSON
- hash = JSON.parse(Zlib::Inflate.inflate(str))
+ hash = JSON.parse(str)
initialize(hash)
end
self
Modified: trunk/spec/base/marshal_dump_spec.rb
==============================================================================
--- trunk/spec/base/marshal_dump_spec.rb (original)
+++ trunk/spec/base/marshal_dump_spec.rb Tue Apr 8 02:20:34 2008
@@ -20,13 +20,13 @@
end
it "should produce valid JSON output when sent the marshal_dump
method" do
- Zlib::Deflate.stub!(:deflate).and_return("Deflated JSON")
+ @h.stub!(:to_json).and_return("Deflated JSON")
@h.marshal_dump.should == 'Deflated JSON'
end
it "should produce valid JSON output when an attribute has been
changed and the marshal_dump method is sent" do
@h.rooms = 200
- Zlib::Deflate.stub!(:deflate).and_return("Deflated JSON, Part deux")
+ @h.stub!(:to_json).and_return("Deflated JSON, Part deux")
@h.marshal_dump.should == 'Deflated JSON, Part deux'
end
end
@@ -58,7 +58,7 @@
it "should produce valid JSON when sent the marshal_dump method" do
# Stub the deflate method, which will basically give us the gzip'd JSON
- Zlib::Deflate.stub!(:deflate).and_return("Deflated JSON, Part three")
+ @c.stub!(:to_json).and_return("Deflated JSON, Part three")
@c.marshal_dump.should == 'Deflated JSON, Part three'
end
end
Modified: trunk/spec/base/marshal_load_spec.rb
==============================================================================
--- trunk/spec/base/marshal_load_spec.rb (original)
+++ trunk/spec/base/marshal_load_spec.rb Tue Apr 8 02:20:34 2008
@@ -32,8 +32,8 @@
it "should instantiate an object when sent the marshal_load method
with valid json as a parameter" do
h = Hotel.new
- Zlib::Inflate.stub!(:inflate).and_return("{\"name\":\"Swissotel
The Stamford\",\"rooms\":200,\"star_rating\":4.0}")
- h = h.marshal_load("About to get inflated!")
+
+ h = h.marshal_load("{\"name\":\"Swissotel The Stamford\",\"rooms\":200,\"star_rating\":4.0}")
h.class.should == Hotel
# Check whether all attributes are set correctly
h.name.should == "Swissotel The Stamford"
@@ -42,9 +42,8 @@
end
it "should instantiate an object when sent the marshal_load method
with valid JSON (containing associations) as a parameter" do
- Zlib::Inflate.stub!(:inflate).and_return('{"name":"Crazed
McLovin","hospitals":[{"name":"Crazy Hospital 1"},{"name":"Crazy
Hospital 2"}]}')
- crazy = CrazyPerson.new.marshal_load("About to get inflated! Part Deux")
+ crazy = CrazyPerson.new.marshal_load('{"name":"Crazed
McLovin","hospitals":[{"name":"Crazy Hospital 1"},{"name":"Crazy
Hospital 2"}]}')
crazy.class.should == CrazyPerson
crazy.name == "Crazed McLovin"
Modified: trunk/spec/base/save_spec.rb
==============================================================================
--- trunk/spec/base/save_spec.rb (original)
+++ trunk/spec/base/save_spec.rb Tue Apr 8 02:20:34 2008
@@ -63,4 +63,28 @@
@person.id.should == 'abc_def'
end
-end
\ No newline at end of file
+end
+
+
+describe "A new ActiveCouch::Base instance" do
+ before(:each) do
+ class Person < ActiveCouch::Base
+ site 'http://localhost:5984/'
+ has :name, :which_is => :text
+ end
+
+ @person = Person.new(:name => 'Seth')
+ # Create a database called people
+ ActiveCouch::Migrator.create_database('http://localhost:5984/', 'people')
+ # Save the document
+ @person.save
+ end
+
+ it "should be allowed to update a field and save again" do
+ @person.name = "McLovin"
+ @person.save.should == true
+
+ @person.name.should == "McLovin"
+ end
+end
+
\ No newline at end of file