rote 0.2.4.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ nil
5
+ end
6
+
7
+ require 'test/unit'
8
+ require 'rote/page'
9
+ require 'rote/format/html'
10
+
11
+ module Rote
12
+ class TestHtmlPage < Test::Unit::TestCase
13
+ include Format::HTML
14
+
15
+ # pretend to be a page
16
+ attr_reader :template_name
17
+
18
+ def test_relative
19
+ @template_name = "three.rhtml"
20
+ assert_equal '', relative('')
21
+ assert_equal 'not-absolute.html', relative('not-absolute.html')
22
+ assert_equal 'doc/not-absolute.html', relative('doc/not-absolute.html')
23
+ assert_equal 'doc/absolute.html', relative('/doc/absolute.html')
24
+ assert_equal 'doc/files/deep/other.html', relative('/doc/files/deep/other.html')
25
+
26
+ @template_name = "one/two/three.rhtml"
27
+ assert_equal 'not-absolute.html', relative('not-absolute.html')
28
+ assert_equal 'doc/not-absolute.html', relative('doc/not-absolute.html')
29
+ assert_equal '../../doc/absolute.html', relative('/doc/absolute.html')
30
+ assert_equal '../../doc/files/deep/other.html', relative('/doc/files/deep/other.html')
31
+ end
32
+ end
33
+ end
data/test/test_page.rb CHANGED
@@ -11,7 +11,16 @@ module Rote
11
11
  class TestPage < Test::Unit::TestCase
12
12
  ############## helpers #################
13
13
  def new_test_page(basename)
14
- Page.new('test/pages/' + basename + '.txt', 'test/layouts')
14
+ Page.new(basename + '.txt', 'test/pages', 'test/layouts')
15
+ end
16
+
17
+ ############## Clz methods ################
18
+ def test_page_ruby_filename
19
+ assert_equal 'test/file.rb', Page::page_ruby_filename('test/file.txt')
20
+ assert_equal '/home/me/test/file.rb', Page::page_ruby_filename('/home/me/test/file.txt')
21
+ assert_equal 'file.rb', Page::page_ruby_filename('file.txt')
22
+ assert_equal 'txt.rb', Page::page_ruby_filename('txt')
23
+ assert_equal '', Page::page_ruby_filename('')
15
24
  end
16
25
 
17
26
  ############## initialize #################
@@ -37,21 +46,74 @@ module Rote
37
46
  end
38
47
 
39
48
  ############## accessors #################
40
- def test_template_accessors
49
+ def test_template_text
41
50
  p = new_test_page('justtext')
42
51
  assert_equal 'Just some text', p.template_text.chomp
43
52
  end
44
53
 
45
- def test_layout_accessors
46
- p = new_test_page('justtext')
54
+ def test_layout_text
55
+ (p = new_test_page('justtext')).render
47
56
  assert_nil p.layout_text
48
57
 
49
- p = new_test_page('withcode')
58
+ (p = new_test_page('withcode')).render
50
59
  assert_equal 'layout <%= @content_for_layout %> for a change.', p.layout_text.chomp
51
60
  end
52
61
 
62
+ def test_base_path
63
+ p = new_test_page('justtext')
64
+ assert_equal 'test/pages', p.base_path
65
+ end
66
+
67
+ def test_layout_path
68
+ p = new_test_page('justtext')
69
+ assert_equal 'test/layouts', p.layout_path
70
+ end
71
+
72
+ def test_template_name
73
+ p = new_test_page('justtext')
74
+ assert_equal 'justtext.txt', p.template_name
75
+ end
76
+
77
+ def test_layout_name
78
+ p = new_test_page('justtext')
79
+ assert_nil p.layout_name
80
+
81
+ p = new_test_page('withcode')
82
+ assert_equal 'simple.txt', p.layout_name
83
+ end
84
+
85
+ def test_template_filename
86
+ p = new_test_page('justtext')
87
+ assert_equal 'test/pages/justtext.txt', p.template_filename
88
+ end
89
+
90
+ def test_layout_filename
91
+ p = new_test_page('justtext')
92
+ assert_nil p.layout_filename
93
+
94
+ p = new_test_page('withcode')
95
+ assert_equal 'test/layouts/simple.txt', p.layout_filename
96
+ end
97
+
98
+ def test_ruby_filename
99
+ p = new_test_page('justtext')
100
+ assert_nil p.ruby_filename
101
+
102
+ p = new_test_page('withcode')
103
+ assert_equal 'test/pages/withcode.rb', p.ruby_filename
104
+ end
105
+
106
+ ############## layout code #################
107
+ def test_layout_code
108
+ (p = new_test_page('withcode')).render
109
+ assert_equal 'test/layouts/simple.txt', p.layout_filename
110
+ assert p.instance_eval { @layout_code_works }
111
+ end
112
+
113
+
114
+ ############## edges #################
53
115
  def test_default_layout_params
54
- p = Page.new('test/pages/samedir.txt')
116
+ (p = Page.new('samedir.txt','test/pages/')).render
55
117
  assert_equal '<%= @global %>', p.template_text.chomp
56
118
  assert_equal 'Lay <%= @content_for_layout %> out.', p.layout_text.chomp
57
119
  end
@@ -68,26 +130,6 @@ module Rote
68
130
 
69
131
  assert_equal 'layout <%= @content_for_layout %> for a change.', p.layout_text.chomp
70
132
  end
71
-
72
- def test_format_opts
73
- p = new_test_page('justtext')
74
- assert p.format_opts.empty?
75
-
76
- # alter array
77
- p = new_test_page('textile')
78
- assert_equal [:textile], p.format_opts
79
- p.format_opts -= [:textile]
80
- assert p.format_opts.empty?
81
-
82
- # replace array with single sym
83
- p = new_test_page('textile')
84
- assert_equal [:textile], p.format_opts
85
- p.format_opts = [:markdown]
86
- assert_equal [:markdown], p.format_opts
87
- p.format_opts = :textile
88
- # should create array for one sim
89
- assert_equal [:textile], p.format_opts
90
- end
91
133
 
92
134
  ############## render #################
93
135
  def test_render_text
@@ -95,28 +137,6 @@ module Rote
95
137
  assert_equal 'Just some text', t
96
138
  end
97
139
 
98
- def test_render_textile
99
- t = new_test_page('textile').render.chomp
100
- assert_equal '<p><strong>This</strong> is a <em>simple</em> test of <a href="http://www.textism.org/tools/textile">Textile</a> formatting.</p>', t
101
- end
102
-
103
- # FIXME Fails under Gem install, but passes when run normally (???)
104
- unless defined?(TEST_FROM_GEM)
105
- def test_render_rdoc
106
- begin
107
- t = new_test_page('rdoc').render.chomp
108
- assert_equal "<h2>RDoc</h2>\n<h3>Markup</h3>", t
109
- rescue Object => ex
110
- p ex
111
- end
112
- end
113
- end
114
-
115
- def test_render_markdown
116
- t = new_test_page('markdown').render.chomp
117
- assert_equal '<h1>*this* is a _test_</h1>', t
118
- end
119
-
120
140
  def test_render_layout_code
121
141
  t = new_test_page('withcode').render.chomp
122
142
  assert_equal 'layout some text and some other text for a change.', t
@@ -125,7 +145,9 @@ module Rote
125
145
  ############## broken render #################
126
146
  def test_render_switch_layout_freeze
127
147
  p = new_test_page('withcode')
128
- assert_equal 'layout <%= @content_for_layout %> for a change.', p.layout_text.chomp
148
+
149
+ # It has a layout, but since it's not rendered it's not loaded yet
150
+ assert_nil p.layout_text
129
151
 
130
152
  p.layout(nil)
131
153
  assert_nil p.layout_text
@@ -140,7 +162,7 @@ module Rote
140
162
  end
141
163
 
142
164
  def test_render_switch_to_bad_layout
143
- p = new_test_page('withcode')
165
+ (p = new_test_page('withcode')).render
144
166
  assert_equal 'layout <%= @content_for_layout %> for a change.', p.layout_text.chomp
145
167
 
146
168
  begin
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rote
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.4.1
7
- date: 2005-12-07 00:00:00 +00:00
6
+ version: 0.3.0
7
+ date: 2005-12-12 00:00:00 +00:00
8
8
  summary: Adds template-based doc support to Rake.
9
9
  require_paths:
10
10
  - lib
@@ -32,6 +32,7 @@ files:
32
32
  - Rakefile
33
33
  - README
34
34
  - TODO
35
+ - DONE
35
36
  - LICENSE
36
37
  - CONTRIBUTORS
37
38
  - bin/rote
@@ -39,8 +40,17 @@ files:
39
40
  - lib/rote/rotetasks.rb
40
41
  - lib/rote/page.rb
41
42
  - lib/rote/app.rb
43
+ - lib/rote/filters.rb
44
+ - lib/rote/format.rb
42
45
  - lib/rote/project/doc/pages/COMMON.rb
43
46
  - lib/rote/project/doc/pages/index.rb
47
+ - lib/rote/format/html.rb
48
+ - lib/rote/filters/rdoc.rb
49
+ - lib/rote/filters/base.rb
50
+ - lib/rote/filters/syntax.rb
51
+ - lib/rote/filters/redcloth.rb
52
+ - lib/rote/filters/toc.rb
53
+ - lib/rote/filters/tidy.rb
44
54
  - lib/rote/builtin.rf
45
55
  - lib/rote/project/Rakefile
46
56
  - lib/rote/project/doc
@@ -52,8 +62,10 @@ files:
52
62
  - lib/rote/project/doc/res/images/rote-tiny.png
53
63
  - lib/rote/project/doc/pages/index.html
54
64
  - lib/rote/project/doc/layouts/normal.html
65
+ - test/test_formatting.rb
55
66
  - test/test_page.rb
56
67
  - test/pages
68
+ - test/test_html_page.rb
57
69
  - test/layouts
58
70
  - test/gem_tests.rb
59
71
  - test/pages/samedir.txt
@@ -70,6 +82,7 @@ files:
70
82
  - test/pages/justtext.txt
71
83
  - test/pages/badlayout.txt
72
84
  - test/pages/withcode.txt
85
+ - test/layouts/simple.rb
73
86
  - test/layouts/withext.ext
74
87
  - test/layouts/simple.txt
75
88
  - doc/res