4 class PStoreTest < Test::Unit::TestCase
6 @pstore_file = "pstore.tmp.#{Process.pid}"
7 @pstore = PStore.new(@pstore_file)
11 File.unlink(@pstore_file) rescue nil
14 def test_opening_new_file_in_readonly_mode_should_result_in_empty_values
15 @pstore.transaction(true) do
16 assert_nil @pstore[:foo]
17 assert_nil @pstore[:bar]
21 def test_opening_new_file_in_readwrite_mode_should_result_in_empty_values
22 @pstore.transaction do
23 assert_nil @pstore[:foo]
24 assert_nil @pstore[:bar]
28 def test_data_should_be_loaded_correctly_when_in_readonly_mode
29 @pstore.transaction do
32 @pstore.transaction(true) do
33 assert_equal "bar", @pstore[:foo]
37 def test_data_should_be_loaded_correctly_when_in_readwrite_mode
38 @pstore.transaction do
41 @pstore.transaction do
42 assert_equal "bar", @pstore[:foo]
46 def test_changes_after_commit_are_discarded
47 @pstore.transaction do
52 @pstore.transaction(true) do
53 assert_equal "bar", @pstore[:foo]
57 def test_changes_are_not_written_on_abort
58 @pstore.transaction do
62 @pstore.transaction(true) do
63 assert_nil @pstore[:foo]
67 def test_writing_inside_readonly_transaction_raises_error
68 assert_raise(PStore::Error) do
69 @pstore.transaction(true) do