Sha256: 12689be20c67950f1e24dca7dcd7d0eaa3f7a23d54cb13f22624ae4789eb8f2d

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Ripple::Document::Timestamps do
  
  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
  end
  
  it "should add a created_at property" do
    @box.should respond_to(:created_at)
  end
  
  it "should add an updated_at property" do
    @box.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
  end
  
  it "should not set the updated_at timestamp when the object is initialized" do
    @box.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
  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)
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ripple-0.6.1 spec/ripple/timestamps_spec.rb
ripple-0.6.0 spec/ripple/timestamps_spec.rb