Sha256: edeb1ef5d6ffb5755da307d2c1a048b9e0e2bfd085da0567dcbfce564a45219e

Contents?: true

Size: 872 Bytes

Versions: 4

Compression:

Stored size: 872 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'couch-migrate'
require 'pathname'

describe CouchMigrate::FilePersistedList do
  let(:path){ Pathname.new("spec/tmp") }
  subject { CouchMigrate::FilePersistedList.new(path) }

  after(:all) do
    Pathname.new(path).delete
  end

  it "starts off with an empty value/list" do
    subject.get.should == []
  end

  it "can set values" do
    arr = [1,2,3]
    subject.set(arr).get.should == arr
  end

  it "can append values" do
    arr = [1,2,3]
    more = [4,5]
    expected = [1,2,3,4,5]

    subject.set(arr).add(more)
    subject.get.should == expected
  end

  it "can be reset" do
    subject.set([1,2,3]).reset
    subject.get.should == []
  end

  it "is chainable" do
    subject.set([1]).add([2]).get.should == [1,2]
    subject.set([1]).add([2]).reset.get.should == []
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couch-migrate-1.1.2 spec/couch_migrate/file_persisted_list_spec.rb
couch-migrate-1.1.1 spec/couch_migrate/file_persisted_list_spec.rb
couch-migrate-1.1.0 spec/couch_migrate/file_persisted_list_spec.rb
couch-migrate-1.0.0 spec/couch_migrate/file_persisted_list_spec.rb