diff --git lib/pstore.rb lib/pstore.rb index 3114eb5..9fb0249 100644 --- lib/pstore.rb +++ lib/pstore.rb @@ -341,6 +341,8 @@ class PStore end end value + rescue ThreadError + raise PStore::Error, "nested transaction" end private diff --git test/test_pstore.rb test/test_pstore.rb index 32d79ea..b6f7925 100644 --- test/test_pstore.rb +++ test/test_pstore.rb @@ -100,4 +100,14 @@ class PStoreTest < Test::Unit::TestCase File.unlink("pstore.tmp2.#{Process.pid}") rescue nil end end + + def test_nested_transaction_raises_error + assert_raise(PStore::Error) do + @pstore.transaction { @pstore.transaction { } } + end + pstore = PStore.new("pstore.tmp2.#{Process.pid}", true) + assert_raise(PStore::Error) do + pstore.transaction { pstore.transaction { } } + end + end end