Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 3158 Bytes
1 | #!/usr/bin/env ruby |
2 | |
3 | require 'test/unit' |
4 | require File.dirname(__FILE__) + '/../lib/haml/engine' |
5 | |
6 | class EngineTest < Test::Unit::TestCase |
7 | |
8 | def render(text, options = {}) |
9 | Haml::Engine.new(text, options).to_html |
10 | end |
11 | |
12 | def test_empty_render_should_remain_empty |
13 | assert_equal('', render('')) |
14 | end |
15 | |
16 | # This is ugly because Hashes are unordered; we don't always know the order |
17 | # in which attributes will be returned. |
18 | # There is probably a better way to do this. |
19 | def test_attributes_should_render_correctly |
20 | assert_equal("<div class='atlantis' style='ugly'>\n</div>", render(".atlantis{:style => 'ugly'}").chomp) |
21 | rescue |
22 | assert_equal("<div style='ugly' class='atlantis'>\n</div>", render(".atlantis{:style => 'ugly'}").chomp) |
23 | end |
24 | |
25 | def test_ruby_code_should_work_inside_attributes |
26 | author = 'hcatlin' |
27 | assert_equal("<p class='3'>foo</p>", render("%p{:class => 1+2} foo").chomp) |
28 | end |
29 | |
30 | def test_nil_should_render_empty_tag |
31 | assert_equal("<div class='no_attributes'>\n</div>", |
32 | render(".no_attributes{:nil => nil}").chomp) |
33 | end |
34 | |
35 | def test_strings_should_get_stripped_inside_tags |
36 | assert_equal("<div class='stripped'>This should have no spaces in front of it</div>", |
37 | render(".stripped This should have no spaces in front of it").chomp) |
38 | end |
39 | |
40 | def test_one_liner_should_be_one_line |
41 | assert_equal("<p>Hello</p>", render('%p Hello').chomp) |
42 | end |
43 | |
44 | def test_long_liner_should_not_print_on_one_line |
45 | assert_equal("<div>\n #{'x' * 51}\n</div>", render("%div #{'x' * 51}").chomp) |
46 | end |
47 | |
48 | def test_multi_render |
49 | engine = Haml::Engine.new("%strong Hi there!") |
50 | assert_equal("<strong>Hi there!</strong>\n", engine.to_html) |
51 | assert_equal("<strong>Hi there!</strong>\n", engine.to_html) |
52 | assert_equal("<strong>Hi there!</strong>\n", engine.to_html) |
53 | end |
54 | |
55 | # Options tests |
56 | |
57 | def test_stop_eval |
58 | assert_equal("", render("= 'Hello'", :suppress_eval => true)) |
59 | end |
60 | |
61 | def test_attr_wrapper |
62 | assert_equal("<p strange=*attrs*>\n</p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) |
63 | assert_equal("<p escaped='quo\"te'>\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) |
64 | assert_equal("<p escaped=\"q'uo"te\">\n</p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"')) |
65 | assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"')) |
66 | end |
67 | |
68 | def test_locals |
69 | assert_equal("<p>Paragraph!</p>\n", render("%p= text", :locals => { :text => "Paragraph!" })) |
70 | end |
71 | |
72 | def test_precompiled |
73 | precompiled = <<-END |
74 | def _haml_render |
75 | _hamlout = @haml_stack[-1] |
76 | _erbout = _hamlout.buffer |
77 | |
78 | _hamlout.open_tag("p", 0, nil, true, "", nil, nil, false) |
79 | @haml_lineno = 1 |
80 | haml_temp = "Haml Rocks Socks" |
81 | haml_temp = _hamlout.push_script(haml_temp, 1, false) |
82 | _hamlout.close_tag("p", 0) |
83 | end |
84 | END |
85 | |
86 | assert_equal("<p>Haml Rocks Socks</p>\n", render("%h1 I shall not be rendered", :precompiled => precompiled)) |
87 | end |
88 | |
89 | def test_comps |
90 | assert_equal(-1, "foo" <=> nil) |
91 | assert_equal(1, nil <=> "foo") |
92 | end |
93 | end |