Sha256: 60776566f43ad314633dc2a05c20aa548f69b3cbb383742b208cc9ed668824dc

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

describe Chicanery::Persistence do
  include Chicanery::Persistence

  describe '#persist' do
    it 'should write state to disk as yaml' do
      file = stub 'file'
      state = stub 'state', to_yaml: :yaml
      File.should_receive(:open).with('state', 'w').and_yield file
      file.should_receive(:puts).with :yaml
      persist state
    end
  end

  describe '#restore' do
    it 'should return empty hash if state file does not exist' do
      File.should_receive(:exist?).with('state').and_return false
      restore.should == {}
    end

    it 'should read yaml from disk' do
      state = stub 'state'
      File.should_receive(:exist?).with('state').and_return true
      YAML.should_receive(:load_file).with('state').and_return state
      restore.should == state
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chicanery-0.0.7 spec/chicanery/persistence_spec.rb
chicanery-0.0.6 spec/chicanery/persistence_spec.rb
chicanery-0.0.5 spec/chicanery/persistence_spec.rb