From 4f8e732fa456863032244422a94718b3e7b46e90 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 18 Nov 2011 06:29:36 -0500 Subject: [PATCH] run the spec file analyzer through the gauntlet --- lib/jasmine/headless/spec_file_analyzer.rb | 2 +- spec/files/UTF-8-test.txt | Bin 0 -> 20334 bytes .../headless/spec_file_analyzer_spec.rb | 73 ++++++++++-------- 3 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 spec/files/UTF-8-test.txt diff --git a/lib/jasmine/headless/spec_file_analyzer.rb b/lib/jasmine/headless/spec_file_analyzer.rb index 0ac0899..f32308d 100644 --- a/lib/jasmine/headless/spec_file_analyzer.rb +++ b/lib/jasmine/headless/spec_file_analyzer.rb @@ -14,7 +14,7 @@ module Jasmine::Headless data = File.read(file) if data.respond_to?(:encode) - data.encode!('US-ASCII', 'UTF-8', :invalid => :replace) + data.encode!('US-ASCII', 'UTF-8', :invalid => :replace, :undef => :replace) else require 'iconv' ic = Iconv.new('UTF-8//IGNORE', 'US-ASCII') diff --git a/spec/files/UTF-8-test.txt b/spec/files/UTF-8-test.txt new file mode 100644 index 0000000000000000000000000000000000000000..abd16f7253bf7254ad1ae04cb5bee8d8c47e407a GIT binary patch literal 20334 zcmdU1X>%Ocb-l=P@_l?QkaQ+KqMb=kWH&#~HSJo~$&h?IO#*?-m zc%Ubgju-S~81=~ARry~yhNh5G^057n(4B1 z-Jl)CU9Yt)Q7lo~@#2A>c;bht2ToHz+%uR?;yu;(!lswhMM+X>Kw223()HXhl{Auu zCoaH4V!C)(1yz@8sk9={!DoAbZN`2Bgt*~QdTyNh&3@ow^nTimx?SUnX>wt*17rPAz z)GE5+b=(6;DHb=Cgmm-*H)9tx`CZcBhe_(WATM%qC1CJyU)%=BH>6_>9koDo+V zLQs$lfz)-uJLDAvP==4s@nApfCw(`-P`!Q%VP8G$d9hE)gDPo5PL>ZR?SRy7gyGtL zoTMwMPwDl+c&u6;Glm2YL9lou@LaqSg&uTj?4lP(5Cu4-)I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Z~UrBQ>|&cjxYja-iJJ1LFWw1pgZE!Xf{69wa!?h1Q=rx^sWU zE6*n1Tg+TJ1!iuWz`Vbr3})sr@WC-U)fLC+eD-E#Iy0X!m<63VW==W9D=MvkIN3 zcEK?K+R;XK`q2I@mD3bGXOX?K;v2HN%Iu{ALzqNFyL=9%@8$v a&2b9W0wR0mw+p!$IoY3(SqK`l>;D0Y6_gYJ literal 0 HcmV?d00001 diff --git a/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb b/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb index fbde25c..5a5dd72 100644 --- a/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb +++ b/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe Jasmine::Headless::SpecFileAnalyzer do - include FakeFS::SpecHelpers let(:file) { 'file' } let(:analyzer) { described_class.new(file) } @@ -11,45 +10,57 @@ describe Jasmine::Headless::SpecFileAnalyzer do analyzer.action end - before do - File.open(file, 'wb') { |fh| fh.print file_data } - end + context 'fake files' do + include FakeFS::SpecHelpers - context 'coffeescript' do - let(:file_data) do - <<-SPEC -describe 'test', -> - context 'yes', -> - it 'should do something', -> - "yes" - "PR.registerLangHandler(PR.createSimpleLexer([[\"com\",/^#[^\\n\\r]*/,null,\"#\"],[\"pln\",/^[\\t\\n\\r \\xa0]+/,null,\"\\t\\n\\r \xC2\\xa0\"],[\"str\",/^\"(?:[^\"\\\\]|\\\\[\\S\\s])*(?:\"|$)/,null,'\"']],[[\"kwd\",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\\s/,\n" -SPEC + before do + File.open(file, 'wb') { |fh| fh.print file_data } end - it 'should get the line numbers' do - line_numbers['test'].should == [ 1 ] - line_numbers['yes'].should == [ 2 ] - line_numbers['should do something'].should == [ 3 ] + context 'coffeescript' do + let(:file_data) do + <<-SPEC + describe 'test', -> + context 'yes', -> + it 'should do something', -> + "yes" + SPEC + end + + it 'should get the line numbers' do + line_numbers['test'].should == [ 1 ] + line_numbers['yes'].should == [ 2 ] + line_numbers['should do something'].should == [ 3 ] + end end - end - context 'javascript' do - let(:file_data) do - <<-SPEC -describe('test', function() { - context('yes', function() { - it('should do something', function() { + context 'javascript' do + let(:file_data) do + <<-SPEC + describe('test', function() { + context('yes', function() { + it('should do something', function() { + }); }); }); -}); -SPEC - end + SPEC + end - it 'should get the line numbers' do - line_numbers['test'].should == [ 1 ] - line_numbers['yes'].should == [ 2 ] - line_numbers['should do something'].should == [ 3 ] + it 'should get the line numbers' do + line_numbers['test'].should == [ 1 ] + line_numbers['yes'].should == [ 2 ] + line_numbers['should do something'].should == [ 3 ] + end + end + end + + context 'utf 8' do + let(:analyzer) { described_class.new('spec/files/UTF-8-test.txt') } + let(:file_data) { '' } + + it 'should not explode' do + line_numbers end end end