hashr 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -1
- data/lib/hashr.rb +4 -0
- data/lib/hashr/version.rb +1 -1
- data/test/hashr_test.rb +16 -8
- metadata +6 -6
data/Rakefile
CHANGED
@@ -3,7 +3,9 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
Rake::TestTask.new do |t|
|
5
5
|
t.libs << 'lib' << 'test'
|
6
|
-
|
6
|
+
# this currently does not work in rake 0.9.2, 0.9.3 will fix it
|
7
|
+
# t.pattern = 'test/**/*_test.rb'
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
7
9
|
t.verbose = false
|
8
10
|
end
|
9
11
|
|
data/lib/hashr.rb
CHANGED
data/lib/hashr/version.rb
CHANGED
data/test/hashr_test.rb
CHANGED
@@ -10,39 +10,47 @@ class HashrTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'method access on an existing key returns the value' do
|
13
|
-
assert_equal 'foo', Hashr.new(
|
13
|
+
assert_equal 'foo', Hashr.new(:foo => 'foo').foo
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'method access on a non-existing key returns nil when raise_missing_keys is false' do
|
17
17
|
Hashr.raise_missing_keys = false
|
18
|
-
assert_nil Hashr.new(
|
18
|
+
assert_nil Hashr.new(:foo => 'foo').bar
|
19
19
|
end
|
20
20
|
|
21
21
|
test 'method access on a non-existing key raises an IndexError when raise_missing_keys is true' do
|
22
22
|
Hashr.raise_missing_keys = true
|
23
|
-
assert_raises(IndexError) { Hashr.new(
|
23
|
+
assert_raises(IndexError) { Hashr.new(:foo => 'foo').bar }
|
24
24
|
end
|
25
25
|
|
26
26
|
test 'method access on an existing nested key returns the value' do
|
27
|
-
assert_equal 'bar', Hashr.new(
|
27
|
+
assert_equal 'bar', Hashr.new(:foo => { :bar => 'bar' }).foo.bar
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'method access on a non-existing nested key returns nil when raise_missing_keys is false' do
|
31
31
|
Hashr.raise_missing_keys = false
|
32
|
-
assert_nil Hashr.new(
|
32
|
+
assert_nil Hashr.new(:foo => { :bar => 'bar' }).foo.baz
|
33
33
|
end
|
34
34
|
|
35
35
|
test 'method access on a non-existing nested key raises an IndexError when raise_missing_keys is true' do
|
36
36
|
Hashr.raise_missing_keys = true
|
37
|
-
assert_raises(IndexError) { Hashr.new(
|
37
|
+
assert_raises(IndexError) { Hashr.new(:foo => { :bar => 'bar' }).foo.baz }
|
38
38
|
end
|
39
39
|
|
40
40
|
test 'method access with a question mark returns true if the key has a value' do
|
41
|
-
assert_equal true, Hashr.new(
|
41
|
+
assert_equal true, Hashr.new(:foo => { :bar => 'bar' }).foo.bar?
|
42
42
|
end
|
43
43
|
|
44
44
|
test 'method access with a question mark returns false if the key does not have a value' do
|
45
|
-
assert_equal false, Hashr.new(
|
45
|
+
assert_equal false, Hashr.new(:foo => { :bar => 'bar' }).foo.baz?
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'hash access is indifferent about symbols/strings (string data given, symbol keys used)' do
|
49
|
+
assert_equal 'bar', Hashr.new('foo' => { 'bar' => 'bar' })[:foo][:bar]
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'hash access is indifferent about symbols/strings (symbol data given, string keys used)' do
|
53
|
+
assert_equal 'bar', Hashr.new(:foo => { :bar => 'bar' })['foo']['bar']
|
46
54
|
end
|
47
55
|
|
48
56
|
test 'mixing symbol and string keys in defaults and data' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70271315078720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70271315078720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test_declarative
|
27
|
-
requirement: &
|
27
|
+
requirement: &70271315078080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.0.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70271315078080
|
36
36
|
description: Simple Hash extension to make working with nested hashes (e.g. for configuration)
|
37
37
|
easier and less error-prone.
|
38
38
|
email: svenfuchs@artweb-design.de
|