期待される出力と実際の出力が同じでも、rspecの仕様が失敗するというJRubyの問題が発生しています。失敗のメッセージは次のとおりです。
Failures:
1) PgArrayParser#parse_pg_array one dimensional arrays NULL values returns an array of strings, with nils replacing NULL characters
Failure/Error: parser.parse_pg_array(%[{1,NULL,NULL}]).should eq ['1',nil,nil]
expected: ["1", nil, nil]
got: ["1", nil, nil]
(compared using ==)
Diff:["1", nil, nil].==(["1", nil, nil]) returned false even though the diff between ["1", nil, nil] and ["1", nil, nil] is empty. Check the implementation of ["1", nil, nil].==.
# ./spec/parser_spec.rb:26:in `(root)'
2) PgArrayParser#parse_pg_array two dimensional arrays strings returns an array of strings with a sub array and a quoted }
Failure/Error: parser.parse_pg_array(%[{1,{"2,}3",NULL},4}]).should eq ['1',['2,}3',nil],'4']
expected: ["1", ["2,}3", nil], "4"]
got: ["1", ["2,}3", nil], "4"]
(compared using ==)
Diff:["1", ["2,}3", nil], "4"].==(["1", ["2,}3", nil], "4"]) returned false even though the diff between ["1", ["2,}3", nil], "4"] and ["1", ["2,}3", nil], "4"] is empty. Check the implementation of ["1", ["2,}3", nil], "4"].==.
# ./spec/parser_spec.rb:69:in `(root)'
3) PgArrayParser#parse_pg_array three dimensional arrays returns an array of strings with sub arrays
Failure/Error: parser.parse_pg_array(%[{1,{2,{3,4}},{NULL,6},7}]).should eq ['1',['2',['3','4']],[nil,'6'],'7']
expected: ["1", ["2", ["3", "4"]], [nil, "6"], "7"]
got: ["1", ["2", ["3", "4"]], [nil, "6"], "7"]
(compared using ==)
Diff:["1", ["2", ["3", "4"]], [nil, "6"], "7"].==(["1", ["2", ["3", "4"]], [nil, "6"], "7"]) returned false even though the diff between ["1", ["2", ["3", "4"]], [nil, "6"], "7"] and ["1", ["2", ["3", "4"]], [nil, "6"], "7"] is empty. Check the implementation of ["
1", ["2", ["3", "4"]], [nil, "6"], "7"].==.
# ./spec/parser_spec.rb:87:in `(root)'
Finished in 0.2 seconds
15 examples, 3 failures
=~
の代わりにを使用するeq
か==
、次の出力を生成しました。
..F.......F..F.
Failures:
1) PgArrayParser#parse_pg_array one dimensional arrays NULL values returns an array of strings, with nils replacing NULL characters
Failure/Error: parser.parse_pg_array(%[{1,NULL,NULL}]).should =~ ['1',nil,nil]
expected collection contained: ["1", nil, nil]
actual collection contained: ["1", nil, nil]
the missing elements were: [nil, nil]
the extra elements were: [nil, nil]
# ./spec/parser_spec.rb:26:in `(root)'
2) PgArrayParser#parse_pg_array two dimensional arrays strings returns an array of strings with a sub array and a quoted }
Failure/Error: parser.parse_pg_array(%[{1,{"2,}3",NULL},4}]).should =~ ['1',['2,}3',nil],'4']
expected collection contained: ["1", ["2,}3", nil], "4"]
actual collection contained: ["1", ["2,}3", nil], "4"]
the missing elements were: [["2,}3", nil]]
the extra elements were: [["2,}3", nil]]
# ./spec/parser_spec.rb:69:in `(root)'
3) PgArrayParser#parse_pg_array three dimensional arrays returns an array of strings with sub arrays
Failure/Error: parser.parse_pg_array(%[{1,{2,{3,4}},{NULL,6},7}]).should =~ ['1',['2',['3','4']],[nil,'6'],'7']
expected collection contained: ["1", ["2", ["3", "4"]], [nil, "6"], "7"]
actual collection contained: ["1", ["2", ["3", "4"]], [nil, "6"], "7"]
the missing elements were: [[nil, "6"]]
the extra elements were: [[nil, "6"]]
# ./spec/parser_spec.rb:87:in `(root)'
Finished in 0.17 seconds
15 examples, 3 failures
スペックはこちらです。注意すべきことは、これらの比較はsを含む唯一のものであるということnil
です。nil
Javaでインスタンス化されたものはJRubyでインスタンス化されたものと同じではないようnil
ですこの問題の回避策を知っている人はいますか?