Data-Liberation-Front / csvlint.rb

The gem behind http://csvlint.io
MIT License
283 stars 86 forks source link

Ruby 2.4 - rspec test failure - Validator Spec - returns stray quote instead of unclosed quote #195

Closed jamesjefferies closed 7 years ago

jamesjefferies commented 7 years ago

Checked out the repository. Rspec tests pass on Ruby 2.1.X, 2.2.X and 2.3.X but a test failure happens on 2.4.0 - not sure why yet, will investigate further. Possibly ordering?

Failures:

  1) Csvlint::Validator validation with multiple lines:  .each() -> `parse_contents` parses malformed CSV and catches unclosed quote
     Failure/Error: expect(validator.errors.first.type).to eql(:unclosed_quote)

       expected: :unclosed_quote
            got: :stray_quote

       (compared using eql?)

       Diff:
       @@ -1,2 +1,2 @@
       -:unclosed_quote
       +:stray_quote
     # ./spec/validator_spec.rb:70:in `block (3 levels) in <top (required)>'
jamesjefferies commented 7 years ago

Ah, after a bit if digging, I think I'm right in that it is actually the Ruby CSV class which throws the error when parse_line is called. I think I was confused as LineCSV also has a parse_line method ;) - so I can only assume that this is a change to how the CSV handles unclosed and stray quotes. In this case, 2.4 considers it a stray quote rather than an unclosed quote.

quadrophobiac commented 7 years ago

Hey @jamesjefferies - did you encounter this while attempting to bring CSVlint into Octopub? I ask given the name of your local branch To create a Ruby 2.4 / Rails 5 compatible version of CSVLint, as it raises a good question of whether this gem needs to be considerate of rails apps its included within

jamesjefferies commented 7 years ago

@quadrophobiac yes, that rings a bell - it's a dependency of Octopub and as we were updating Octopub to 2.4/5 I created that branch of CSVlint which was compatible and therefore could be used..

Floppy commented 7 years ago

I've "resolved" this in the tests now. I can't make Ruby throw a stray quote error on 2.4, so for now it's in there but pending. The unclosed quote test is improved to make more sense, and works fine.