Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def initialize(file, thread_safe = false)
if File::exist? file and not File::readable? file
raise PStore::Error, format("file %s not readable", file)
end
@filename = file
@filename = File.path(file)
@abort = false
@ultra_safe = false
@thread_safe = thread_safe
Expand Down
11 changes: 11 additions & 0 deletions test/test_pstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'test/unit'
require 'pstore'
require 'tmpdir'
require 'pathname'

class PStoreTest < Test::Unit::TestCase
def setup
Expand Down Expand Up @@ -296,4 +297,14 @@ def test_interrupted_atomic_save_removes_temporary_file
File.define_singleton_method(:new, original_new) if original_new
Dir.glob("#{@pstore_file}.tmp.*").each { |path| File.unlink(path) rescue nil }
end

def test_path_like_filename_is_normalized
store = PStore.new(Pathname(@pstore_file))
store.ultra_safe = true
store.transaction { store[:foo] = "bar" }

assert_instance_of(String, store.path)
assert_equal(@pstore_file, store.path)
assert_equal("bar", store.transaction(true) { store[:foo] })
end
end