From b04bb49879375e61385a842981ae30f9fcadf2fe Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 10 Oct 2011 09:32:27 -0400 Subject: [PATCH] add 1.9.3-rc1 test support and fix #70 --- Rakefile | 18 +++++++++++++++--- lib/jasmine/files_list.rb | 2 -- lib/jasmine/headless/spec_file_analyzer.rb | 13 ++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index db8bed4..26779e0 100644 --- a/Rakefile +++ b/Rakefile @@ -14,12 +14,23 @@ require 'jasmine/headless/task' Jasmine::Headless::Task.new +PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1} + +def rvm_bundle(command = '') + Bundler.with_clean_env do + system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} ruby bundle #{command}'}.tap { |o| p o } + end +end + +class SpecFailure < StandardError; end +class BundleFailure < StandardError; end + namespace :spec do desc "Run on three Rubies" task :platforms do - system %{rvm 1.8.7,1.9.2,ree ruby bundle} - system %{rvm 1.8.7,1.9.2,ree ruby bundle exec rake spec} - raise StandardError.new if $?.exitstatus != 0 + rvm_bundle + rvm_bundle "exec rspec spec" + raise SpecError.new if $?.exitstatus != 0 end end @@ -31,3 +42,4 @@ task :build_runner do system %{ruby extconf.rb} end end + diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index 2764b28..2295111 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -1,5 +1,4 @@ require 'jasmine-core' -require 'iconv' require 'time' require 'multi_json' @@ -64,7 +63,6 @@ module Jasmine alert_time = nil end - function_locations = {} source = nil result = case File.extname(file) diff --git a/lib/jasmine/headless/spec_file_analyzer.rb b/lib/jasmine/headless/spec_file_analyzer.rb index 252b067..0ac0899 100644 --- a/lib/jasmine/headless/spec_file_analyzer.rb +++ b/lib/jasmine/headless/spec_file_analyzer.rb @@ -1,4 +1,3 @@ -require 'iconv' require 'multi_json' module Jasmine::Headless @@ -12,8 +11,16 @@ module Jasmine::Headless def action line_numbers = {} - ic = Iconv.new('UTF-8//IGNORE', 'US-ASCII') - data = ic.iconv(File.read(file) + ' ')[0..-2] + data = File.read(file) + + if data.respond_to?(:encode) + data.encode!('US-ASCII', 'UTF-8', :invalid => :replace) + else + require 'iconv' + ic = Iconv.new('UTF-8//IGNORE', 'US-ASCII') + data = ic.iconv(File.read(file) + ' ')[0..-2] + end + data.force_encoding('US-ASCII') if data.respond_to?(:force_encoding) data.lines.each_with_index.each { |line, index|