Sha256: 0fda496cf63b7b19f9de0947d370c33a63f926ca64c6287125b6032cd14c4740

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe "JasonObject" do
  before :each do
    @user = User.new
  end

  after :each do
    @user.delete!
  end

  it "should be comparable to other JasonObjects" do
    @user.save!
    (@user == User.new).should eq(false)
    (@user == @user).should eq(true)
    (@user == User.get_by_key(@user.jason_key, :lazy)).should eq(true)
    (@user == User.get_by_key(@user.jason_key)).should eq(true)
    (@user == "Hello world?").should eq(false)
    (@user == @user.jason_key).should eq(false)
  end

  it "should be persistable" do
    @user.name = "Freddy"
    @user.save!

    @user.jason_state.should eq(:stale)

    retrieved_user = User.get_by_key @user.jason_key
    retrieved_user.name.should eq(@user.name)
  end

  it "should track it's state" do
    @user.jason_state.should eq(:new)
    @user.save!
    @user.name = "Freddy"
    @user.jason_state.should eq(:dirty)
    @user.save!
    @user.jason_state.should eq(:stale)

    retrieved_user = User.get_by_key @user.jason_key, :lazy
    retrieved_user.jason_state.should eq(:ghost)
    retrieved_user.name
    retrieved_user.jason_state.should eq(:stale)
  end

  it "should not load deleted objects" do
    u = User.new
    u.name = "Michael"
    u.save!
    u.delete!
    User.all.each do |usr|
      usr.should_not eq(u)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
medea-0.3.1 spec/jason_object_spec.rb