Sha256: 51f994c72b58637bdd3e38e0df27890dc81d969f6a00d308ea95edecbb3432f9

Contents?: true

Size: 1.29 KB

Versions: 7

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 its 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

7 entries across 7 versions & 1 rubygems

Version Path
medea-0.4.0 spec/jason_object_spec.rb
medea-0.3.7 spec/jason_object_spec.rb
medea-0.3.6 spec/jason_object_spec.rb
medea-0.3.5 spec/jason_object_spec.rb
medea-0.3.4 spec/jason_object_spec.rb
medea-0.3.3 spec/jason_object_spec.rb
medea-0.3.2 spec/jason_object_spec.rb