lib/vex/base/enumerable/deep.rb in vex-0.4.2 vs lib/vex/base/enumerable/deep.rb in vex-0.4.4
- old
+ new
@@ -45,10 +45,11 @@
when Array
if mode & VALUES
o.inject([]) do |r, v|
v = reject(v, mode, &block)
r << v unless yield(v)
+ r
end
else
o.dup
end
else
@@ -79,12 +80,24 @@
h = { :a => "a", :b_c => { :d => nil, :video_test => "video_test "}, "x" => nil, "y" => [] }
expected = { :a=>"a", :b_c => { :video_test => "video_test " }}
assert_equal(expected, h.reject_blanks)
end
+ def test_reject_blanks_w_array
+ h = { :a => "a", :b_c => [{ :d => nil}, {:video_test => "video_test "}], "x" => nil, "y" => [] }
+ expected = { :a=>"a", :b_c => [{ :video_test => "video_test " }]}
+ assert_equal(expected, h.reject_blanks)
+ end
+
def test_camelized_keys
h = { :a => "a", :b_c => { :d => "dd", :video_test => "video_test "}}
expected = { "A"=>"a", "BC" => { "VideoTest" => "video_test ", "D" => "dd" }}
+ assert_equal(expected, h.camelize)
+ end
+
+ def test_camelized_keys_w_array
+ h = { :a => "a", :b_c => [{ :d => "dd"}, {:video_test => "video_test "}]}
+ expected = { "A"=>"a", "BC" => [{"D" => "dd" }, { "VideoTest" => "video_test "}]}
assert_equal(expected, h.camelize)
end
def test_missin_block
assert_raise(LocalJumpError) {