Sha256: c3c1a75141a926df4de8f4c7fa70670adff4d562a083783ad6f9f309c3c5e650

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

module Voicemail
  describe StoragePstore do
    let(:mailbox) do
      {
        id:               100,
        pin:              1234,
        greeting_message: nil,
        send_email:       true,
        email_address:    'lpradovera@mojolingo.com'
      }
    end

    let(:config) { Voicemail::Plugin.config }

    subject :storage do
      basedir = File.expand_path("../../../tmp/", __FILE__)
      pstore_path = File.join(basedir, 'voicemail.pstore')
      File.unlink(pstore_path) if File.exists?(pstore_path)
      config.storage.pstore_location = pstore_path
      StoragePstore.new.tap do |storage|
        storage.store.transaction do
          storage.store[:mailboxes][100] = mailbox
        end
        flexmock storage
      end
    end

    it "is a PStore" do
      storage.store.should be_a PStore
    end

    describe "#get_mailbox" do
      it "returns the mailbox if it exists" do
        storage.get_mailbox(100).should == mailbox
      end

      it "returns nil if the mailbox does not exist" do
        storage.get_mailbox(400).should be_nil
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voicemail-0.2.0 spec/voicemail/storage_pstore_spec.rb
voicemail-0.1.0 spec/voicemail/storage_pstore_spec.rb