Skip to content

Commit

Permalink
Attempt to fix Cucumber::CODEPAGE error again for Windows [#561 state…
Browse files Browse the repository at this point in the history
…:resolved]
  • Loading branch information
aslakhellesoy committed Mar 11, 2010
1 parent 4f2b799 commit 717780e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion cucumber.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aslak Helles\303\270y"]
s.date = %q{2010-03-02}
s.date = %q{2010-03-11}
s.default_executable = %q{cucumber}
s.description = %q{A BDD tool written in Ruby}
s.email = %q{cukes@googlegroups.com}
Expand Down Expand Up @@ -332,6 +332,7 @@ Gem::Specification.new do |s|
"features/bug_371.feature",
"features/bug_464.feature",
"features/bug_475.feature",
"features/bug_585_tab_indentation.feature",
"features/call_many_steps.feature",
"features/cucumber_cli.feature",
"features/cucumber_cli_diff_disabled.feature",
Expand Down Expand Up @@ -359,6 +360,7 @@ Gem::Specification.new do |s|
"features/rerun_formatter.feature",
"features/simplest.feature",
"features/snippet.feature",
"features/snippets_when_using_star_keyword.feature",
"features/step_definitions/cucumber_steps.rb",
"features/step_definitions/extra_steps.rb",
"features/step_definitions/simplest_steps.rb",
Expand Down
22 changes: 11 additions & 11 deletions lib/cucumber/formatter/unicode.rb
Expand Up @@ -7,6 +7,17 @@
if Cucumber::WINDOWS
require 'iconv'

if ENV['CUCUMBER_OUTPUT_ENCODING']
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
elsif Cucumber::WINDOWS_MRI
Cucumber::CODEPAGE = "cp#{Win32::Console::OutputCP()}"
elsif `cmd /c chcp` =~ /(\d+)/
Cucumber::CODEPAGE = "cp#{$1.to_i}"
else
Cucumber::CODEPAGE = "cp1252"
STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
end

module Cucumber
module WindowsOutput #:nodoc:
def self.extended(o)
Expand Down Expand Up @@ -44,15 +55,4 @@ def puts(*a)
STDERR.extend(self)
end
end

if ENV['CUCUMBER_OUTPUT_ENCODING']
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
elsif Cucumber::WINDOWS_MRI
Cucumber::CODEPAGE = "cp#{Win32::Console::OutputCP()}"
elsif `cmd /c chcp` =~ /(\d+)/
Cucumber::CODEPAGE = "cp#{$1.to_i}"
else
Cucumber::CODEPAGE = "cp1252"
STDERR.cucumber_puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
end
end

0 comments on commit 717780e

Please sign in to comment.