Skip to content

Commit 121cf5a

Browse files
herwinweregon
authored andcommitted
Small improvoments to specs of Hash.[]
* Remove all validations inside a block that should raise, this code should never be executed. * Update the spec with `[:nil]`, to use `[nil]` instead. The old code tested the exact same thing as `[:a]` above it.
1 parent b833642 commit 121cf5a

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

core/hash/constructor_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,20 @@
4444

4545
it "raises for elements that are not arrays" do
4646
-> {
47-
Hash[[:a]].should == {}
47+
Hash[[:a]]
4848
}.should raise_error(ArgumentError)
4949
-> {
50-
Hash[[:nil]].should == {}
50+
Hash[[nil]]
5151
}.should raise_error(ArgumentError)
5252
end
5353

5454
it "raises an ArgumentError for arrays of more than 2 elements" do
55-
->{ Hash[[[:a, :b, :c]]].should == {} }.should raise_error(ArgumentError)
55+
->{ Hash[[[:a, :b, :c]]] }.should raise_error(ArgumentError)
5656
end
5757

5858
it "raises an ArgumentError when passed a list of value-invalid-pairs in an array" do
5959
-> {
60-
-> {
61-
Hash[[[:a, 1], [:b], 42, [:d, 2], [:e, 2, 3], []]]
62-
}.should complain(/ignoring wrong elements/)
60+
Hash[[[:a, 1], [:b], 42, [:d, 2], [:e, 2, 3], []]]
6361
}.should raise_error(ArgumentError)
6462
end
6563

0 commit comments

Comments
 (0)