spec/ripple/timestamps_spec.rb in ripple-0.6.1 vs spec/ripple/timestamps_spec.rb in ripple-0.7.0

- old
+ new

@@ -1,49 +1,42 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Ripple::Document::Timestamps do + require 'support/models/clock' - before :all do - Object.module_eval { class Box; include Ripple::Document; property :shape, String; timestamps! end } - end - before :each do response = {:headers => {"content-type" => ["application/json"]}, :body => "{}"} @client = Ripple.client @http = mock("HTTP Backend", :get => response, :put => response, :post => response, :delete => response) @client.stub!(:http).and_return(@http) - @box = Box.new + @clock = Clock.new end it "should add a created_at property" do - @box.should respond_to(:created_at) + @clock.should respond_to(:created_at) end it "should add an updated_at property" do - @box.should respond_to(:updated_at) + @clock.should respond_to(:updated_at) end it "should set the created_at timestamp when the object is initialized" do - @box.created_at.should_not be_nil + @clock.created_at.should_not be_nil end it "should not set the updated_at timestamp when the object is initialized" do - @box.updated_at.should be_nil + @clock.updated_at.should be_nil end it "should set the updated_at timestamp when the object is created" do - @box.save - @box.updated_at.should_not be_nil + @clock.save + @clock.updated_at.should_not be_nil end it "should update the updated_at timestamp when the object is updated" do - @box.save - start = @box.updated_at - @box.save - @box.updated_at.should > start - end - - after :all do - Object.send(:remove_const, :Box) + @clock.save + start = @clock.updated_at + @clock.save + @clock.updated_at.should > start end end