diff --git a/lib/csv.rb b/lib/csv.rb index 45a087ff0f..b16e817d09 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -870,7 +870,8 @@ class CSV # Returns +true+ if all rows of this table ==() +other+'s rows. def ==(other) - @table == other.table + return @table == other.table if other.is_a? CSV::Table + @table == other end # diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb index 3f9359faaf..8acd744b73 100755 --- a/test/csv/test_features.rb +++ b/test/csv/test_features.rb @@ -374,4 +374,7 @@ class TestCSV::Features < TestCSV assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a end + def test_table_nil_equality + assert_nothing_raised(NoMethodError) { CSV.parse("test", headers: true) == nil } + end end