feldtruby 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/feldtruby/array.rb +6 -0
- data/lib/feldtruby.rb +1 -1
- data/test/test_array.rb +15 -1
- metadata +1 -1
data/lib/feldtruby/array.rb
CHANGED
data/lib/feldtruby.rb
CHANGED
data/test/test_array.rb
CHANGED
@@ -68,4 +68,18 @@ describe "Array extensions" do
|
|
68
68
|
]
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
|
+
describe "add_unless_there" do
|
73
|
+
it "adds an element when array is empty" do
|
74
|
+
[].add_unless_there(1).must_equal [1]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "adds an element when array is NOT empty" do
|
78
|
+
[1,2].add_unless_there(3).must_equal [1,2,3]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "does nothing when element is already in array" do
|
82
|
+
[1,2,3].add_unless_there(3).must_equal [1,2,3]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|