File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ class IRubyTest ::MimeTest < IRubyTest ::TestBase
2+ sub_test_case ( "IRuby::Display" ) do
3+ def test_display_with_mime_type
4+ html = "<b>Bold Text</b>"
5+
6+ obj = Object . new
7+ obj . define_singleton_method ( :to_s ) { html }
8+
9+ res = IRuby ::Display . display ( obj , mime : "text/html" )
10+ assert_equal ( { plain : obj . inspect , html : html } ,
11+ { plain : res [ "text/plain" ] , html : res [ "text/html" ] } )
12+ end
13+ end
14+
15+ sub_test_case ( "Rendering a file" ) do
16+ def setup
17+ @html = "<b>Bold Text</b>"
18+ Dir . mktmpdir do |tmpdir |
19+ @file = File . join ( tmpdir , "test.html" )
20+ File . write ( @file , @html )
21+ yield
22+ end
23+ end
24+
25+ def test_display
26+ File . open ( @file , "rb" ) do |f |
27+ res = IRuby ::Display . display ( f )
28+ assert_equal ( @html , res [ "text/html" ] )
29+ end
30+ end
31+ end
32+ end
You can’t perform that action at this time.
0 commit comments