Skip to content

Commit fd1e5fd

Browse files
herwinweregon
authored andcommitted
Include message validation in expected exception of Hash.[]
1 parent 121cf5a commit fd1e5fd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

core/hash/constructor_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@
4545
it "raises for elements that are not arrays" do
4646
-> {
4747
Hash[[:a]]
48-
}.should raise_error(ArgumentError)
48+
}.should raise_error(ArgumentError, "wrong element type Symbol at 0 (expected array)")
4949
-> {
5050
Hash[[nil]]
51-
}.should raise_error(ArgumentError)
51+
}.should raise_error(ArgumentError, "wrong element type nil at 0 (expected array)")
5252
end
5353

5454
it "raises an ArgumentError for arrays of more than 2 elements" do
55-
->{ Hash[[[:a, :b, :c]]] }.should raise_error(ArgumentError)
55+
->{
56+
Hash[[[:a, :b, :c]]]
57+
}.should raise_error(ArgumentError, "invalid number of elements (3 for 1..2)")
5658
end
5759

5860
it "raises an ArgumentError when passed a list of value-invalid-pairs in an array" do
5961
-> {
6062
Hash[[[:a, 1], [:b], 42, [:d, 2], [:e, 2, 3], []]]
61-
}.should raise_error(ArgumentError)
63+
}.should raise_error(ArgumentError, "wrong element type Integer at 2 (expected array)")
6264
end
6365

6466
describe "passed a single argument which responds to #to_hash" do

0 commit comments

Comments
 (0)