Skip to content

Commit

Permalink
unnecessary to_s removed
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed May 28, 2010
1 parent 9d67842 commit a746657
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/test_mimemagic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
end

it 'should recognize extensions' do
MimeMagic.by_extension('.html').to_s.should.equal 'text/html'
MimeMagic.by_extension('html').to_s.should.equal 'text/html'
MimeMagic.by_extension(:html).to_s.should.equal 'text/html'
MimeMagic.by_extension('rb').to_s.should.equal 'application/x-ruby'
MimeMagic.by_extension('.html').should.equal 'text/html'
MimeMagic.by_extension('html').should.equal 'text/html'
MimeMagic.by_extension(:html).should.equal 'text/html'
MimeMagic.by_extension('rb').should.equal 'application/x-ruby'
MimeMagic.by_extension('crazy').should.equal nil
MimeMagic.by_extension('').should.equal nil
end

it 'should recognize by magic' do
Dir['test/files/*'].each do |file|
mime = file[11..-1].gsub('.', '/')
MimeMagic.by_magic(File.read(file)).to_s.should.equal mime
MimeMagic.by_magic(File.open(file, 'rb')).to_s.should.equal mime
MimeMagic.by_magic(File.read(file)).should.equal mime
MimeMagic.by_magic(File.open(file, 'rb')).should.equal mime
end
end

Expand All @@ -49,8 +49,8 @@
:extensions => %w(ext1 ext2),
:parents => 'application/xml',
:comment => 'Comment')
MimeMagic.by_extension('ext1').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_extension('ext2').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_extension('ext1').should.equal 'application/mimemagic-test'
MimeMagic.by_extension('ext2').should.equal 'application/mimemagic-test'
MimeMagic.by_extension('ext2').comment.should.equal 'Comment'
MimeMagic.new('application/mimemagic-test').extensions.should.equal %w(ext1 ext2)
MimeMagic.new('application/mimemagic-test').should.be.child_of 'text/plain'
Expand All @@ -62,11 +62,11 @@
[1, 'MAGICTEST'], # MAGICTEST at position 1
[2, 'MAGICTEST', [[0, 'X'], [0, 'Y']]]]) # MAGICTEST at position 2 and (X at 0 or Y at 0)

MimeMagic.by_magic('MAGICTEST').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_magic('XMAGICTEST').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_magic(' MAGICTEST').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_magic('X MAGICTEST').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_magic('Y MAGICTEST').to_s.should.equal 'application/mimemagic-test'
MimeMagic.by_magic('MAGICTEST').should.equal 'application/mimemagic-test'
MimeMagic.by_magic('XMAGICTEST').should.equal 'application/mimemagic-test'
MimeMagic.by_magic(' MAGICTEST').should.equal 'application/mimemagic-test'
MimeMagic.by_magic('X MAGICTEST').should.equal 'application/mimemagic-test'
MimeMagic.by_magic('Y MAGICTEST').should.equal 'application/mimemagic-test'
MimeMagic.by_magic('Z MAGICTEST').should.equal nil
end
end

0 comments on commit a746657

Please sign in to comment.