Permalink
Browse files

Remove rspec dependency, replace with Test::Unit testcase

  • Loading branch information...
1 parent a1ff6d3 commit 5519c3e41d8f6857884c31ac24033aea65542a39 @peterkovacs peterkovacs committed Sep 7, 2012
Showing with 21 additions and 82 deletions.
  1. +21 −82 spec/all.rb
View
@@ -1,119 +1,58 @@
-#require 'bacon'
-#Bacon.summary_on_exit
+require 'test/unit'
require File.dirname( __FILE__ ) + '/../lib/rchardet'
-describe CharDet do
- def chardet_spec_detect(file)
+class TestCharDet < Test::Unit::TestCase
+
+ def assert_chardet_spec_detect(file, expected)
content = File.open("spec/asset/#{file}.txt", 'rb'){|io| io.read }
- CharDet.detect(content)
+ assert_equal expected, CharDet.detect(content)
end
- it 'detect EUC-JP' do
- chardet_spec_detect('EUC-JP').should == {
+ def test_detect_EUC_JP
+ assert_chardet_spec_detect 'EUC-JP', {
"encoding" => 'EUC-JP', "confidence" => 0.99
}
end
- it 'detect Shift_JIS' do
- chardet_spec_detect('Shift_JIS').should == {
+ def test_detect_Shift_JIS
+ assert_chardet_spec_detect 'Shift_JIS', {
"encoding" => 'SHIFT_JIS', "confidence" => 1
}
end
- it 'detect UTF-8' do
- chardet_spec_detect('UTF-8').should == {
+ def test_detect_UTF_8
+ assert_chardet_spec_detect 'UTF-8' , {
"encoding" => 'utf-8', "confidence" => 0.99
}
end
- it 'detect eucJP-ms' do
- chardet_spec_detect('eucJP-ms').should == {
+ def test_detect_eucJP_ms
+ assert_chardet_spec_detect 'eucJP-ms' , {
"encoding" => 'EUC-JP', "confidence" => 0.99
}
end
- it 'detect UTF-16BE' do
- chardet_spec_detect('UTF-16BE').should == {
+ def test_detect_UTF_16BE
+ assert_chardet_spec_detect 'UTF-16BE' , {
"encoding" => 'UTF-16BE', "confidence" => 1
}
end
- it 'detect UTF-16LE' do
- chardet_spec_detect('UTF-16LE').should == {
+ def test_detect_UTF_16LE
+ assert_chardet_spec_detect 'UTF-16LE' , {
"encoding" => 'UTF-16LE', "confidence" => 1
}
end
- it 'detect ISO-2022-JP' do
- chardet_spec_detect( 'ISO-2022-JP' ).should == {
+ def test_detect_ISO_2022_JP
+ assert_chardet_spec_detect 'ISO-2022-JP' , {
"encoding" => 'ISO-2022-JP', "confidence" => 0.99
}
end
- it 'detect big5' do
- chardet_spec_detect( 'big5' ).should == {
+ def test_detect_big5
+ assert_chardet_spec_detect 'big5' , {
"encoding" => 'Big5', "confidence" => 0.99
}
end
end
-
-__END__
-# all the specs down here fail, i don't expect passes until i can find files in
-# that encoding
-
- describe 'CP51932' do
- it 'detects correctly' do
- chardet_spec_detect('CP51932').should == {
- "encoding" => Encoding":CP51932," "confidence" => 0.99
- }
- end
- end
-
- describe 'GB18030' do
- it 'detects correctly' do
- chardet_spec_detect('GB18030').should == {
- "encoding" => Encoding":GB18030," "confidence" => 0.99
- }
- end
- end
-
- describe 'UTF-32BE' do
- it 'detects correctly' do
- chardet_spec_detect('UTF-32BE').should == {
- "encoding" => Encoding":UTF_32BE," "confidence" => 0.99
- }
- end
- end
-
- describe 'EUC-JP' do
- it 'detects correctly' do
- chardet_spec_detect('EUC-JP').should == {
- "encoding" => nil, "confidence" => 0.99
- }
- end
- end
-
- describe 'UTF-32LE' do
- it 'detects correctly' do
- chardet_spec_detect('UTF-32LE').should == {
- "encoding" => Encoding":UTF_32LE," "confidence" => 0.99
- }
- end
- end
-
- describe 'Windows-31J' do
- it 'detects correctly' do
- chardet_spec_detect('Windows-31J').should == {
- "encoding" => nil, "confidence" => 0.99
- }
- end
- end
-
- describe 'stateless-ISO-2022-JP' do
- it 'detects correctly' do
- chardet_spec_detect('stateless-ISO-2022-JP').should == {
- "encoding" => nil, "confidence" => 0.99
- }
- end
- end
-end

0 comments on commit 5519c3e

Please sign in to comment.