r-cochran / cuke_sniffer

A ruby library used to root out smells in your cukes.
MIT License
44 stars 28 forks source link

InvalidByteSequence Error when using inline method #78

Open snowe2010 opened 9 years ago

snowe2010 commented 9 years ago

I'm getting an InvalidByteSequenceError when attempting to use cuke_sniffer inline. I've got these lines in my env.rb file

# Start cuke_sniffer to analyze all code only on Jenkins
if ENV['JENKINS_HOME']
  cuke_sniffer = CukeSniffer::CLI.new
end
...
if ENV['JENKINS_HOME']
  cuke_sniffer.output_html('t.html')
end

When I run cucumber I get this error when it tries to write the file.

Assessing Score:
"\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cuke_sniffer-0.0.8/lib/cuke_sniffer/formatter.rb:59:in `write'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cuke_sniffer-0.0.8/lib/cuke_sniffer/formatter.rb:59:in `block in output_html'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cuke_sniffer-0.0.8/lib/cuke_sniffer/formatter.rb:58:in `open'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cuke_sniffer-0.0.8/lib/cuke_sniffer/formatter.rb:58:in `output_html'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cuke_sniffer-0.0.8/lib/cuke_sniffer/cli.rb:130:in `output_html'
C:/Users/tyler.thrailkill/Documents/recondo/tools/watir2_0/trunk/features/support/env.rb:56:in `<top (required)>'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load_code_file'

C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:237:in `load_file'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `each'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:242:in `load_step_definitions'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:65:in `run!'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/lib/cucumber/cli/main.rb:38:in `execute!'
C:/tools/ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.0/bin/cucumber:9:in `<top (required)>'
C:/tools/ruby193/bin/cucumber:23:in `load'
C:/tools/ruby193/bin/cucumber:23:in `<main>'
r-cochran commented 9 years ago

At a glance this looks like a character issue, most likely in a feature/scenario name or step definition matcher. If you can, hunt down the offending file and identify any unicode character that might have been introduced. If this is a recent issue I'd start with the latest code submitted. I'll try and follow up on this in the next week.

Another option is to open the formatter class in the gem and print out the output before the failure and post it here and I can pick through it, if you don't feel comfortable doing that I more than understand.

snowe2010 commented 9 years ago

Yeah that's the thing, it only happens when I run it inline. I can run through the command line with output as html and it works perfectly fine.

I did find some unicode characters, took a while though. It was opening and closing double quotes instead of straight quotes. I don't understand why it worked running through the command line though, writing to the same output.

It does work now btw.

vaughncm commented 9 years ago

Marking this as a bug so that we can revisit it. If you could provide us the offending source file that caused the issue that would be lovely. Otherwise replication may not be possible at time of analysis.