Sha256: 98bef573b4254c92b9f502af24343999f83e62b4802d82e413049163c773df05

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

require 'fedux_org/stdlib/models'

describe Models::BaseModel do

  before(:each) {
    Models::BaseModel.clear
  }

  it "is possible to register a message" do
    m1 = Models::BaseModel.new('name')
    Models::BaseModel.register m1
  end

  it "is possible to find an object" do
    m1 = Models::BaseModel.new('name')
    Models::BaseModel.register m1

    m_found = Models::BaseModel.find('name')

    expect(m1).to eq(m_found)
  end

  it "is possible to create and register in one step" do
    m1 = Models::BaseModel.create('name')
    m_found = Models::BaseModel.find('name')

    expect(m1).to eq(m_found)
  end

  it "is possible to delete an object" do
    m1 = Models::BaseModel.create('name')
    m2 = Models::BaseModel.delete('name')

    expect(m1).to eq(m2)
  end

  it "is possible to delete all objects" do
    Models::BaseModel.create('name1')
    Models::BaseModel.create('name2')
    Models::BaseModel.create('name3')

    Models::BaseModel.clear
    expect(Models::BaseModel.all).to eq( [] )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.0.3 spec/models/base_model_spec.rb