Sha256: 4fc9b4a6d8f1b0ea7841cf22ce8c4a4074914c8d37eca55e8751b80a81f08d55
Contents?: true
Size: 1.7 KB
Versions: 5
Compression:
Stored size: 1.7 KB
Contents
describe Settings::ValueStore do it 'should require_reload? after initialization' do @store = Settings::ValueStore.new(Settings::Root.new) @store.should be_need_reload end it 'should always reload on reload == true' do @store = Settings::ValueStore.new(Settings::Root.new, :reload => true) @store.load @store.should be_need_reload end it 'should never reload on reload == false' do @store = Settings::ValueStore.new(Settings::Root.new, :reload => false) @store.load @store.should_not be_need_reload end it 'should reload after x seconds on reload == x' do @store = Settings::ValueStore.new(Settings::Root.new, :reload => 1) @store.load @store.should_not be_need_reload sleep 1 @store.should be_need_reload end it 'should reload on file mtime change on reload == "some path"' do # Set test file path and create/update it path = File.join(Dir.tmpdir, 'settings-test.txt') FileUtils.touch(path) # Set our store to reload based on that file @store = Settings::ValueStore.new(Settings::Root.new, :reload => path) @store.load @store.should_not be_need_reload # Sleep a bit (needed due to OSX mtime resolution of 1 second... grr) sleep 1.1 FileUtils.touch(path) @store.should be_need_reload end it 'should reload conditionally on reload == { some proc }' do # Set reload to a lambda referencing a locally scoped variable, toggle variable and # ensure need_reload? toggles as well... doit = true @store = Settings::ValueStore.new(Settings::Root.new, :reload => lambda { doit }) @store.load @store.should be_need_reload doit = false @store.should_not be_need_reload end end
Version data entries
5 entries across 5 versions & 1 rubygems