-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from ruby/dbm-psych-4
Use `safe_load` instead of `load`
- Loading branch information
Showing
4 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
source "https://rubygems.org" | ||
|
||
group :development do | ||
gem "bundler" | ||
gem "rake" | ||
gem "test-unit" | ||
gem "test-unit-ruby-core" | ||
|
||
gem "pstore" | ||
gem "dbm" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "test/unit" | ||
require "yaml/dbm" | ||
|
||
class TestYAMLDBM < Test::Unit::TestCase | ||
def setup | ||
@dbm = YAML::DBM.new("test") | ||
end | ||
|
||
def teardown | ||
@dbm.close | ||
File.unlink("test.db") | ||
end | ||
|
||
def test_fetch | ||
@dbm["key"] = "value" | ||
assert_equal "value", @dbm["key"] | ||
assert_equal "value", @dbm.fetch("key") | ||
end | ||
|
||
def test_delete | ||
@dbm["key"] = "value" | ||
assert_equal "value", @dbm.delete("key") | ||
assert_nil @dbm["key"] | ||
end | ||
|
||
def test_each_value | ||
@dbm["key1"] = "value1" | ||
@dbm["key2"] = "value2" | ||
@dbm.each_value do |value| | ||
assert_match(/value[12]/, value) | ||
end | ||
end | ||
|
||
def test_values | ||
@dbm["key1"] = "value1" | ||
@dbm["key2"] = "value2" | ||
@dbm.values.each do |value| | ||
assert_match(/value[12]/, value) | ||
end | ||
end | ||
|
||
def test_shift | ||
@dbm["key"] = "value" | ||
assert_equal ["key", "value"], @dbm.shift | ||
end | ||
end if defined?(YAML::DBM) |