diff --git a/History.md b/History.md index 49dbc55950..b3f24f4057 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +## [Git master](https://github.com/cucumber/cucumber/compare/v1.2.3...master) + +### New Features + +### Bugfixes +* Fix problem with non-ascii characters in file path ([#150](https://github.com/cucumber/cucumber/issues/150) Oleg Sukhodolsky) + ## [1.2.3](https://github.com/cucumber/cucumber/compare/v1.2.2...v1.2.3) ### Bugfixes diff --git a/lib/cucumber/core_ext/proc.rb b/lib/cucumber/core_ext/proc.rb index a72927c87f..8e47bd387b 100644 --- a/lib/cucumber/core_ext/proc.rb +++ b/lib/cucumber/core_ext/proc.rb @@ -1,4 +1,5 @@ # Proc extension to get more location info out of a proc +require 'cucumber/platform' class Proc #:nodoc: PROC_PATTERN = /[\d\w]+@(.+):(\d+).*>/ PWD = Dir.pwd @@ -16,6 +17,7 @@ def file_colon_line path, line = *to_s.match(PROC_PATTERN)[1..2] path = File.expand_path(path) pwd = File.expand_path(PWD) + pwd.force_encoding(path.encoding) unless Cucumber::RUBY_1_8_7 if path.index(pwd) path = path[pwd.length+1..-1] elsif path =~ /.*\/gems\/(.*\.rb)$/ diff --git a/spec/cucumber/core_ext/proc_spec.rb b/spec/cucumber/core_ext/proc_spec.rb index 5f912a0a42..f39aa1f451 100644 --- a/spec/cucumber/core_ext/proc_spec.rb +++ b/spec/cucumber/core_ext/proc_spec.rb @@ -1,10 +1,22 @@ +# encoding: utf-8 require 'spec_helper' require 'cucumber/core_ext/proc' describe Proc do it "should remove extraneous path info for file" do proc = lambda {|a,b|} - proc.file_colon_line.should =~ /^spec\/cucumber\/core_ext\/proc_spec\.rb:6/ + proc.file_colon_line.should =~ /^spec\/cucumber\/core_ext\/proc_spec\.rb:7/ + end + + unless Cucumber::RUBY_1_8_7 + it "should work with non-English path" do + proc = lambda {|a,b|} + def proc.to_s + "#".force_encoding('ASCII-8BIT') + end + + proc.file_colon_line.force_encoding('UTF-8').should =~ /^å\/spec\/cucumber\/core_ext\/proc_spec\.rb:12/ + end end it "should raise ArityMismatchError for too many args (expecting 0)" do