Sha256: 56b4b9ae21af4fe1c91f40b2b620fb13254b73ce082f14eed7c500ae8afff61c
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require_relative '../spec_helper' describe Chicanery::Persistence do include Chicanery::Persistence let(:file) { double 'file' } let(:state) { double 'state', to_yaml: :yaml } describe '#persist' do it 'should write state to disk as yaml' do File.should_receive(:open).with('state', 'w').and_yield file file.should_receive(:puts).with :yaml persist state end it 'should persist state to where it is told' do persist_state_to 'foo' File.should_receive(:open).with('foo', '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 File.should_receive(:exist?).with('state').and_return true YAML.should_receive(:load_file).with('state').and_return state restore.should == state end it 'should read yaml from another location if it is told to do so' do persist_state_to 'foo' File.should_receive(:exist?).with('foo').and_return true YAML.should_receive(:load_file).with('foo').and_return state restore.should == state end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chicanery-0.2.0 | spec/chicanery/persistence_spec.rb |
chicanery-0.1.9 | spec/chicanery/persistence_spec.rb |