Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mimemagic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
mimemagic
Commits
d0a68fd9
Commit
d0a68fd9
authored
Dec 20, 2009
by
Daniel Mendler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test to spec
parent
02b22e2e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
test/test_mimemagic.rb
+23
-20
No files found.
test/test_mimemagic.rb
View file @
d0a68fd9
gem
'test-unit'
,
'>= 0'
gem
'test-spec'
,
'>= 0'
require
'test/unit'
require
'test/spec'
require
'mimemagic'
class
TC_MimeMagic
<
Test
::
Unit
::
TestCase
def
test_text?
assert
MimeMagic
.
new
(
'text/plain'
).
text?
assert
MimeMagic
.
new
(
'text/html'
).
text?
assert
!
MimeMagic
.
new
(
'application/octet-stream'
).
text?
assert
!
MimeMagic
.
new
(
'image/png'
).
text?
describe
'MimeMagic'
do
it
'should have text? helper'
do
MimeMagic
.
new
(
'text/plain'
).
should
.
be
.
text
MimeMagic
.
new
(
'text/html'
).
should
.
be
.
text
MimeMagic
.
new
(
'application/octet-stream'
).
should
.
be
.
not
.
text
MimeMagic
.
new
(
'image/png'
).
should
.
be
.
not
.
text
end
def
test_child_of?
assert
MimeMagic
.
new
(
'text/html'
).
child_of?
(
'text/plain'
)
assert
MimeMagic
.
new
(
'text/x-java'
).
child_of?
(
'text/plain'
)
it
'should have hierarchy'
do
MimeMagic
.
new
(
'text/html'
).
should
.
be
.
child_of
'text/plain'
MimeMagic
.
new
(
'text/x-java'
).
should
.
be
.
child_of
'text/plain'
end
def
test_extensions
assert_equal
%w(htm html)
,
MimeMagic
.
new
(
'text/html'
).
extensions
it
'should have extensions'
do
MimeMagic
.
new
(
'text/html'
).
extensions
.
should
==
%w(htm html)
end
def
test_by_extension
assert_equal
'text/html'
,
MimeMagic
.
by_extension
(
'html'
).
to_s
assert_equal
'application/x-ruby'
,
MimeMagic
.
by_extension
(
'rb'
).
to_s
assert_nil
MimeMagic
.
by_extension
(
'crazy'
)
assert_nil
MimeMagic
.
by_extension
(
''
)
it
'should recognize extensions'
do
MimeMagic
.
by_extension
(
'html'
).
to_s
.
should
==
'text/html'
MimeMagic
.
by_extension
(
'rb'
).
to_s
.
should
==
'application/x-ruby'
MimeMagic
.
by_extension
(
'crazy'
).
should
==
nil
MimeMagic
.
by_extension
(
''
).
should
==
nil
end
def
test_by_magic
assert_equal
'application/x-executable'
,
MimeMagic
.
by_magic
(
File
.
open
(
'/bin/ls'
)).
to_s
assert_equal
'application/x-sharedlib'
,
MimeMagic
.
by_magic
(
File
.
open
(
'/lib/libc.so.6'
)).
to_s
it
'should recognize by magic'
do
MimeMagic
.
by_magic
(
File
.
open
(
'/bin/ls'
)).
to_s
.
should
==
'application/x-executable'
MimeMagic
.
by_magic
(
File
.
open
(
'/lib/libc.so.6'
)).
to_s
.
should
==
'application/x-sharedlib'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment