cucumber-attic / gherkin2

A fast Gherkin parser in Ragel (The parser behind Cucumber)
MIT License
381 stars 220 forks source link

Ruby 2.0 - error in features/pretty_formatter.feature:13 #232

Open voxik opened 11 years ago

voxik commented 11 years ago

Hi, running $ LANG=C cucumber using Ruby 2.0, I get the following error:

  @no-javascript
  Scenario: Parse all the features in Cucumber with JSON                     # features/pretty_formatter.feature:13
    Given I have Cucumber's source code next to Gherkin's                    # features/step_definitions/pretty_formatter_steps.rb:50
    And I find all of the .feature files                                     # features/step_definitions/pretty_formatter_steps.rb:55
    When I send each prettified original through the "json" machinery        # features/step_definitions/pretty_formatter_steps.rb:59
      "\xD9" on US-ASCII
      Fatal error happened when parsing /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/features/step_definitions/../../../cucumber/examples/i18n/ar/features/addition.feature. (Encoding::InvalidByteSequenceError)
      ./features/step_definitions/pretty_formatter_steps.rb:28:in `json_machinery'
      ./features/step_definitions/pretty_formatter_steps.rb:65:in `block (2 levels) in <top (required)>'
      ./features/step_definitions/pretty_formatter_steps.rb:61:in `/^I send each prettified original through the "([^"]*)" machinery$/'
      features/pretty_formatter.feature:16:in `When I send each prettified original through the "json" machinery'
    Then the machinery output should be identical to the prettified original # features/step_definitions/pretty_formatter_steps.rb:83

The same scenario passes with Ruby 1.9.3. Might it be because change in default Ruby encoding? Anyway, the encoding should be somewhere specified probably.

voxik commented 11 years ago

Actually there seems to be similar issues with RSpec test suite as well. I list here just one for illustration:

  1) C Lexer it should behave like encoding with BOM should work just fine
     Failure/Error: scan_file("with_bom.feature")
     ArgumentError:
       invalid byte sequence in US-ASCII
     Shared Example Group: "encoding" called from ./spec/gherkin/c_lexer_spec.rb:18
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/lib/gherkin/lexer/encoding.rb:31:in `=~'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/lib/gherkin/lexer/encoding.rb:31:in `block in encoding'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/lib/gherkin/lexer/encoding.rb:30:in `each_line'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/lib/gherkin/lexer/encoding.rb:30:in `encoding'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/lib/gherkin/lexer/encoding.rb:12:in `read_file'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/spec/spec_helper.rb:28:in `fixture'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/spec/spec_helper.rb:23:in `scan_file'
     # /builddir/build/BUILD/usr/share/gems/gems/gherkin-2.11.6/spec/gherkin/shared/encoding_group.rb:9:in `block (3 levels) in <module:Lexer>'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example.rb:114:in `instance_eval'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example.rb:114:in `block in run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example.rb:254:in `with_around_each_hooks'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example.rb:111:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:388:in `block in run_examples'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:384:in `map'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:384:in `run_examples'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:369:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `block in run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `map'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `block in run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `map'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/example_group.rb:370:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:28:in `map'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:28:in `block in run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/reporter.rb:34:in `report'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:25:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:80:in `run'
     # /usr/share/gems/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'