Sha256: b3de8e2372f809245e02684f6467e629c18b840ac1a3b8821addad216cea11ce

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

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

class ResourceFoo
  include HashPersistent::Resource
end


describe "A class that includes HashPersistent::Resource" do
  it "should acquire a store attribute" do
    resource = ResourceFoo.new
    resource.store = "foo"
    resource.store.should == "foo"
  end

  it "should acquire a key attribute" do
    resource = ResourceFoo.new
    resource.key = "foo"
    resource.key.should == "foo"
  end

  it "should be savable to its store" do
    resource = ResourceFoo.new
    mock_store = "dummy"
    resource.store = mock_store
    
    mock_store.should_receive(:save).with(resource)
    resource.save
  end

  it "should be deletable from its store" do
    resource = ResourceFoo.new
    mock_store = "dummy"
    resource.store = mock_store
    
    mock_store.should_receive(:delete).with(resource)
    resource.delete
  end

  it "should be movable from one store to another" do
    resource = ResourceFoo.new
    mock_store = "dummy" # We use only one so that we can use rspec to check the order of the messages...
    resource.store = mock_store
    
    mock_store.should_receive(:delete).with(resource).ordered
    mock_store.should_receive(:save).with(resource).ordered
    resource.move(mock_store)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kissifer-hash-persistent-0.0.0 spec/resource_spec.rb