staticpress 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data.tar.gz.sig +0 -0
  2. data/docs/Gemfile +8 -0
  3. data/{tests/sample_sites/test_blog → docs}/README.markdown +0 -0
  4. data/{tests/sample_sites/test_blog → docs}/config.ru +0 -0
  5. data/docs/config.yml +2 -0
  6. data/docs/content/docs/diving-deeper.markdown +3 -0
  7. data/docs/content/docs/setup.markdown +15 -0
  8. data/docs/content/index.markdown +1 -0
  9. data/features/happy_path.feature +36 -1
  10. data/features/step_definitions/staticpress_steps.rb +1 -1
  11. data/lib/skeleton/Gemfile +0 -2
  12. data/lib/staticpress/booter.rb +1 -1
  13. data/lib/staticpress/cli.rb +2 -2
  14. data/lib/staticpress/content/base.rb +66 -23
  15. data/lib/staticpress/content/category.rb +12 -3
  16. data/lib/staticpress/content/collection_content.rb +0 -4
  17. data/lib/staticpress/content/index.rb +10 -3
  18. data/lib/staticpress/content/page.rb +32 -17
  19. data/lib/staticpress/content/post.rb +22 -27
  20. data/lib/staticpress/content/resource_content.rb +11 -3
  21. data/lib/staticpress/content/static_content.rb +10 -4
  22. data/lib/staticpress/content/tag.rb +12 -3
  23. data/lib/staticpress/content/theme.rb +17 -19
  24. data/lib/staticpress/helpers.rb +4 -0
  25. data/lib/staticpress/route.rb +21 -95
  26. data/lib/staticpress/server.rb +1 -3
  27. data/lib/staticpress/site.rb +20 -16
  28. data/lib/staticpress/version.rb +1 -1
  29. data/tests/staticpress/configuration_test.rb +4 -0
  30. data/tests/staticpress/content/base_test.rb +271 -0
  31. data/tests/staticpress/content/category_test.rb +29 -0
  32. data/tests/staticpress/content/index_test.rb +6 -0
  33. data/tests/staticpress/content/page_test.rb +37 -0
  34. data/tests/staticpress/content/post_test.rb +45 -0
  35. data/tests/staticpress/content/tag_test.rb +33 -0
  36. data/tests/staticpress/content/theme_test.rb +29 -0
  37. data/tests/{lib/staticpress → staticpress}/helpers_test.rb +2 -2
  38. data/tests/staticpress/js_object_test.rb +43 -0
  39. data/tests/staticpress/metadata_test.rb +16 -0
  40. data/tests/staticpress/plugin_test.rb +4 -0
  41. data/tests/staticpress/pusher_test.rb +9 -0
  42. data/tests/{lib/staticpress → staticpress}/route_test.rb +19 -41
  43. data/tests/{lib/staticpress → staticpress}/server_test.rb +5 -14
  44. data/tests/staticpress/site_test.rb +21 -0
  45. data/tests/staticpress/theme_test.rb +86 -0
  46. data/tests/staticpress/view_helpers_test.rb +28 -0
  47. data/tests/{lib/staticpress_test.rb → staticpress_test.rb} +3 -3
  48. data/tests/{sample_sites/test_blog → test_blog}/Gemfile +0 -2
  49. data/tests/test_blog/README.markdown +21 -0
  50. data/tests/test_blog/config.ru +8 -0
  51. data/tests/{sample_sites/test_blog → test_blog}/config.yml +0 -0
  52. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-07-20-hello.markdown +0 -0
  53. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-01-announcing-staticpress.markdown +0 -0
  54. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-02-staticpress.markdown +0 -0
  55. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-06-blogging-with-staticpress.markdown +0 -0
  56. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-06-conferences.markdown +0 -0
  57. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-06-in-charlotte.markdown +0 -0
  58. data/tests/{sample_sites/test_blog → test_blog}/content/_posts/2011-08-20-forever.markdown +0 -0
  59. data/tests/{sample_sites/test_blog → test_blog}/content/about.markdown +0 -0
  60. data/tests/{sample_sites/test_blog → test_blog}/content/contact.markdown +0 -0
  61. data/tests/{sample_sites/test_blog → test_blog}/content/foo/bar/baz.markdown +0 -0
  62. data/tests/test_blog/content/index.markdown +1 -0
  63. data/tests/{sample_sites/test_blog → test_blog}/content/plain.txt +0 -0
  64. data/tests/{sample_sites/test_blog → test_blog}/content/ruby.png +0 -0
  65. data/tests/{sample_sites/test_blog → test_blog}/content/style1.css +0 -0
  66. data/tests/{sample_sites/test_blog → test_blog}/content/style2.css.sass +0 -0
  67. data/tests/{sample_sites/test_blog → test_blog}/content/style3.sass +0 -0
  68. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/assets/scripts/application.js +0 -0
  69. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/assets/styles/all.sass +0 -0
  70. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/includes/list_posts.haml +0 -0
  71. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/layouts/archive.haml +0 -0
  72. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/layouts/atom.haml +0 -0
  73. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/layouts/default.haml +0 -0
  74. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/layouts/index.haml +0 -0
  75. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/layouts/post_index.haml +0 -0
  76. data/tests/{sample_sites/test_blog → test_blog}/themes/test_theme/views/default.haml +0 -0
  77. data/tests/{test_helper.rb → test_case.rb} +9 -5
  78. metadata +81 -73
  79. metadata.gz.sig +0 -0
  80. data/tests/lib/staticpress/configuration_test.rb +0 -4
  81. data/tests/lib/staticpress/content/base_test.rb +0 -6
  82. data/tests/lib/staticpress/content/category_test.rb +0 -62
  83. data/tests/lib/staticpress/content/index_test.rb +0 -45
  84. data/tests/lib/staticpress/content/page_test.rb +0 -147
  85. data/tests/lib/staticpress/content/post_test.rb +0 -89
  86. data/tests/lib/staticpress/content/tag_test.rb +0 -60
  87. data/tests/lib/staticpress/content/theme_test.rb +0 -114
  88. data/tests/lib/staticpress/js_object_test.rb +0 -45
  89. data/tests/lib/staticpress/metadata_test.rb +0 -19
  90. data/tests/lib/staticpress/plugin_test.rb +0 -4
  91. data/tests/lib/staticpress/pusher_test.rb +0 -9
  92. data/tests/lib/staticpress/site_test.rb +0 -26
  93. data/tests/lib/staticpress/theme_test.rb +0 -86
  94. data/tests/lib/staticpress/view_helpers_test.rb +0 -33
metadata.gz.sig CHANGED
Binary file
@@ -1,4 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- class ConfigurationTest < TestHelper
4
- end
@@ -1,6 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- require 'staticpress/content/base'
4
-
5
- class ContentBaseTest < TestHelper
6
- end
@@ -1,62 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/category'
4
- require 'staticpress/route'
5
- require 'staticpress/theme'
6
-
7
- class ContentCategoryTest < ContentBaseTest
8
- def setup
9
- super
10
-
11
- @template_dir = Staticpress::Theme.theme.root + 'views'
12
-
13
- @category_page_route = Staticpress::Route.from_url_path '/category/programming'
14
- @category_page = Staticpress::Content::Category.new @category_page_route, @template_dir + 'default.haml'
15
- end
16
-
17
- def test__equalsequals
18
- assert_operator @category_page, :==, Staticpress::Content::Category.new(@category_page_route, @template_dir + 'default.haml')
19
- refute_operator @category_page, :==, nil
20
- end
21
-
22
- def test_categories
23
- assert_equal [ 'programming', 'travel' ], Staticpress::Content::Category.categories
24
- end
25
-
26
- def test_exist?
27
- assert @category_page.exist?, '@category_page does not exist'
28
- end
29
-
30
- def test_find_by_route
31
- assert_equal @category_page, Staticpress::Content::Category.find_by_route(@category_page_route)
32
- end
33
-
34
- def test_inspect
35
- assert_equal '#<Staticpress::Content::Category url_path=/category/programming>', @category_page.inspect
36
- end
37
-
38
- def test_sub_content
39
- assert_equal 3, @category_page.sub_content.count
40
- end
41
-
42
- def test_raw
43
- assert_equal '= partial :list_posts, :posts => page.sub_content', @category_page.raw
44
- end
45
-
46
- def test_route
47
- assert_equal '/category/programming', @category_page.route.url_path
48
- end
49
-
50
- def test_all
51
- assert_equal 2, Staticpress::Content::Category.all.count
52
- assert Staticpress::Content::Category.all.include?(@category_page)
53
- end
54
-
55
- def test_content_by_category
56
- [
57
- Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '01', :title => 'announcing-staticpress').content,
58
- Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '02', :title => 'staticpress').content,
59
- Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress').content
60
- ].each { |content| assert_includes Staticpress::Content::Category.content_by_category['programming'], content }
61
- end
62
- end
@@ -1,45 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/index'
4
- require 'staticpress/route'
5
-
6
- class ContentIndexTest < ContentBaseTest
7
- def setup
8
- super
9
-
10
- @template_dir = Staticpress::Theme.theme.root + 'views'
11
-
12
- @home_route = Staticpress::Route.from_url_path '/'
13
- @home = Staticpress::Content::Index.new @home_route, @template_dir + 'default.haml'
14
-
15
- @home_two_route = Staticpress::Route.from_url_path '/page/2'
16
- @home_two = Staticpress::Content::Index.new @home_two_route, @template_dir + 'default.haml'
17
- end
18
-
19
- def test__equalsequals
20
- assert_operator @home, :==, Staticpress::Content::Index.new(@home_route, @template_dir + 'default.haml')
21
- refute_operator @home, :==, @home_two
22
- refute_operator @home, :==, nil
23
- end
24
-
25
- def test_exist?
26
- assert @home.exist?, '@home does not exist'
27
- end
28
-
29
- def test_find_by_route
30
- assert_equal @home, Staticpress::Content::Index.find_by_route(@home_route)
31
- end
32
-
33
- def test_inspect
34
- assert_equal '#<Staticpress::Content::Index url_path=/>', @home.inspect
35
- assert_equal '#<Staticpress::Content::Index url_path=/page/2>', @home_two.inspect
36
- end
37
-
38
- def test_raw
39
- end
40
-
41
- def test_route
42
- assert_equal '/', @home.route.url_path
43
- assert_equal '/page/2', @home_two.route.url_path
44
- end
45
- end
@@ -1,147 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/page'
4
- require 'staticpress/helpers'
5
- require 'staticpress/route'
6
-
7
- class ContentPageTest < ContentBaseTest
8
- include Staticpress::Helpers
9
-
10
- def setup
11
- super
12
-
13
- @page_dir = Staticpress.blog_path + config.source_path
14
-
15
- @page_route = Staticpress::Route.from_url_path '/about'
16
- @page = Staticpress::Content::Page.new @page_route, @page_dir + 'about.markdown'
17
-
18
- @second_page_route = Staticpress::Route.from_url_path '/contact'
19
- @second_page = Staticpress::Content::Page.new @second_page_route, @page_dir + 'contact.markdown'
20
-
21
- @style2_route = Staticpress::Route.from_url_path '/style2.css'
22
- @style2 = Staticpress::Content::Page.new @style2_route, @page_dir + 'style2.css.sass'
23
-
24
- @nested_route = Staticpress::Route.from_url_path '/foo/bar/baz'
25
- @nested = Staticpress::Content::Page.new @nested_route, @page_dir + 'foo' + 'bar' + 'baz'
26
-
27
- @static_bin_route = Staticpress::Route.from_url_path '/ruby.png'
28
- @static_bin = Staticpress::Content::Page.new @static_bin_route, @page_dir + 'ruby.png'
29
-
30
- @static_txt_route = Staticpress::Route.from_url_path '/plain.txt'
31
- @static_txt = Staticpress::Content::Page.new @static_txt_route, @page_dir + 'plain.txt'
32
- end
33
-
34
- def test__equalsequals
35
- assert_operator @page, :==, Staticpress::Content::Page.new(@page_route, @page_dir + 'about.markdown')
36
- refute_operator @page, :==, @second_page
37
- refute_operator @page, :==, nil
38
- assert_operator @static_bin, :==, Staticpress::Content::Page.new(@static_bin_route, @page_dir + 'ruby.png')
39
- refute_operator @static_bin, :==, nil
40
- refute_operator @static_bin, :==, @static_txt
41
- end
42
-
43
- def test_all
44
- assert_equal 8, Staticpress::Content::Page.all.count
45
- end
46
-
47
- def test_content_type
48
- assert_equal 'text/html', @page.content_type
49
- assert_equal 'text/css', @style2.content_type
50
- assert_equal 'image/png', @static_bin.content_type
51
- assert_equal 'text/plain', @static_txt.content_type
52
- end
53
-
54
- def test_exist?
55
- assert @page.exist?, '@page does not exist'
56
- assert @second_page.exist?, '@second_page does not exist'
57
- assert @static_bin.exist?, '@static_bin does not exist'
58
- assert @static_txt.exist?, '@static_txt does not exist'
59
- end
60
-
61
- def test_find_by_path
62
- @page_dir = Staticpress.blog_path + config.source_path
63
- assert_equal @page, Staticpress::Content::Page.find_by_path(@page_dir + 'about.markdown')
64
- assert_nil Staticpress::Content::Page.find_by_path(@page_dir + 'i' + 'dont' + 'exist.markdown')
65
- assert_equal @static_bin, Staticpress::Content::Page.find_by_path(@page_dir + 'ruby.png')
66
- assert_nil Staticpress::Content::Page.find_by_path(@page_dir + 'i' + 'dont' + 'exist.jpg')
67
- end
68
-
69
- def test_find_by_route
70
- assert_equal @page, Staticpress::Content::Page.find_by_route(@page_route)
71
- assert_nil Staticpress::Content::Page.find_by_route(nil)
72
- assert_equal @static_bin, Staticpress::Content::Page.find_by_route(@static_bin_route)
73
- assert_nil Staticpress::Content::Page.find_by_route(nil)
74
- end
75
-
76
- def test_inspect
77
- assert_equal '#<Staticpress::Content::Page url_path=/about>', @page.inspect
78
- assert_equal '#<Staticpress::Content::Page url_path=/ruby.png>', @static_bin.inspect
79
- end
80
-
81
- def test_output_path
82
- assert_equal (Staticpress.blog_path + 'public' + 'about' + 'index.html'), @page.output_path
83
- assert_equal (Staticpress.blog_path + 'public' + 'style2.css'), @style2.output_path
84
- assert_equal (Staticpress.blog_path + 'public' + 'ruby.png'), @static_bin.output_path
85
- assert_equal (Staticpress.blog_path + 'public' + 'plain.txt'), @static_txt.output_path
86
- end
87
-
88
- def test_raw
89
- assert_equal 'in page', @page.raw
90
- assert_equal "in page\n\nin page", @second_page.raw
91
- assert_equal 'this file intentionally left blank', @static_txt.raw
92
- end
93
-
94
- def test_render
95
- expected_page = <<-HTML
96
- <!DOCTYPE html>
97
- <html>
98
- <head>
99
- <title>About | Test Blog</title>
100
- </head>
101
- <body>
102
- <p>in page</p>
103
- </body>
104
- </html>
105
- HTML
106
- assert_equal expected_page, @page.render
107
-
108
- expected_style2 = <<-CSS
109
- body{color:green}
110
- CSS
111
- assert_equal expected_style2, @style2.render
112
- assert_equal 'this file intentionally left blank', @static_txt.render
113
- end
114
-
115
- def test_render_partial
116
- assert_equal "<p>in page</p>\n", @page.render_partial
117
- assert_equal "<p>in page</p>\n\n<p>in page</p>\n", @second_page.render_partial
118
- expected_style2 = <<-CSS
119
- body{color:green}
120
- CSS
121
- assert_equal expected_style2, @style2.render_partial
122
- assert_equal 'this file intentionally left blank', @static_txt.render_partial
123
- end
124
-
125
- def test_route
126
- assert_equal '/about', @page.route.url_path
127
- assert_equal '/contact', @second_page.route.url_path
128
- assert_equal '/ruby.png', @static_bin.route.url_path
129
- assert_equal '/plain.txt', @static_txt.route.url_path
130
- end
131
-
132
- def test_save
133
- @static_bin.save
134
- assert_equal @static_bin.template_path.binread, @static_bin.output_path.binread
135
-
136
- @static_txt.save
137
- assert_equal @static_txt.template_path.read, @static_txt.output_path.read
138
- end
139
-
140
- def test_full_title
141
- assert_equal 'Foo -> Bar -> Baz | Test Blog', @nested.full_title
142
- end
143
-
144
- def test_title
145
- assert_equal 'Foo -> Bar -> Baz', @nested.title
146
- end
147
- end
@@ -1,89 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/post'
4
- require 'staticpress/helpers'
5
- require 'staticpress/route'
6
-
7
- class ContentPostTest < ContentBaseTest
8
- include Staticpress::Helpers
9
-
10
- def setup
11
- super
12
-
13
- @post_dir = Staticpress.blog_path + config.posts_source_path
14
-
15
- @post_route = Staticpress::Route.from_url_path '/2011/07/20/hello'
16
- @post = Staticpress::Content::Post.new @post_route, @post_dir + '2011-07-20-hello.markdown'
17
-
18
- @another_post_route = Staticpress::Route.from_url_path '/2011/08/20/forever'
19
- @another_post = Staticpress::Content::Post.new @another_post_route, @post_dir + '2011-08-20-forever.markdown'
20
-
21
- @long_title_post_route = Staticpress::Route.from_url_path '/2011/08/06/blogging-with-staticpress'
22
- @long_title_post = Staticpress::Content::Post.new @long_title_post_route, @post_dir + '2011-08-06-blogging-with-staticpress.markdown'
23
- end
24
-
25
- def test__equalsequals
26
- assert_operator @post, :==, Staticpress::Content::Post.new(@post_route, @post_dir + '2011-07-20-hello.markdown')
27
- refute_operator @post, :==, nil
28
- end
29
-
30
- def test__spaceship
31
- assert_operator @post, :<=>, @another_post
32
- assert_operator @another_post, :<=>, @post
33
- assert_equal [ @post, @another_post ], [ @post, @another_post ].sort
34
- assert_equal [ @post, @another_post ], [ @another_post, @post ].sort
35
- end
36
-
37
- def test_created_at
38
- assert_equal Time.utc(2011, 7, 20, 13, 9, 52), @post.created_at
39
- assert_equal Time.utc(2011, 8, 20), @another_post.created_at
40
- end
41
-
42
- def test_created_on
43
- assert_equal Time.utc(2011, 7, 20), @post.created_on
44
- assert_equal Time.utc(2011, 8, 20), @another_post.created_on
45
- end
46
-
47
- def test_exist?
48
- assert @post.exist?, '@post does not exist'
49
- end
50
-
51
- def test_find_by_path
52
- @post_dir = Staticpress.blog_path + config.posts_source_path
53
- assert_equal @post, Staticpress::Content::Post.find_by_path(@post_dir + '2011-07-20-hello.markdown')
54
- assert_nil Staticpress::Content::Post.find_by_path(@post_dir + '2011-07-20-goodbye.markdown')
55
- end
56
-
57
- def test_find_by_route
58
- assert_equal @post, Staticpress::Content::Post.find_by_route(@post_route)
59
- assert_nil Staticpress::Content::Post.find_by_route(nil)
60
- end
61
-
62
- def test_inspect
63
- assert_equal '#<Staticpress::Content::Post url_path=/2011/07/20/hello>', @post.inspect
64
- end
65
-
66
- def test_output_path
67
- assert_equal (Staticpress.blog_path + 'public' + '2011' + '07' + '20' + 'hello' + 'index.html'), @post.output_path
68
- end
69
-
70
- def test_raw
71
- assert_equal 'in post', @post.raw
72
- end
73
-
74
- def test_render
75
- end
76
-
77
- def test_render_partial
78
- assert_equal "<p>in post</p>\n", @post.render_partial
79
- end
80
-
81
- def test_route
82
- assert_equal '/2011/07/20/hello', @post.route.url_path
83
- end
84
-
85
- def test_title
86
- assert_equal 'Hello, World', @post.title
87
- assert_equal 'Blogging With Staticpress', @long_title_post.title
88
- end
89
- end
@@ -1,60 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/tag'
4
- require 'staticpress/route'
5
- require 'staticpress/theme'
6
-
7
- class ContentTagTest < ContentBaseTest
8
- def setup
9
- super
10
-
11
- @template_dir = Staticpress::Theme.theme.root + 'views'
12
-
13
- @tag_page_route = Staticpress::Route.from_url_path '/tag/charlotte'
14
- @tag_page = Staticpress::Content::Tag.new @tag_page_route, @template_dir + 'default.haml'
15
- end
16
-
17
- def test__equalsequals
18
- assert_operator @tag_page, :==, Staticpress::Content::Tag.new(@tag_page_route, @template_dir + 'default.haml')
19
- refute_operator @tag_page, :==, nil
20
- end
21
-
22
- def test_tags
23
- assert_equal [ 'charlotte' ], Staticpress::Content::Tag.tags
24
- end
25
-
26
- def test_exist?
27
- assert @tag_page.exist?, '@tag_page does not exist'
28
- end
29
-
30
- def test_find_by_route
31
- assert_equal @tag_page, Staticpress::Content::Tag.find_by_route(@tag_page_route)
32
- end
33
-
34
- def test_inspect
35
- assert_equal '#<Staticpress::Content::Tag url_path=/tag/charlotte>', @tag_page.inspect
36
- end
37
-
38
- def test_sub_content
39
- assert_equal 1, @tag_page.sub_content.count
40
- end
41
-
42
- def test_raw
43
- assert_equal '= partial :list_posts, :posts => page.sub_content', @tag_page.raw
44
- end
45
-
46
- def test_route
47
- assert_equal '/tag/charlotte', @tag_page.route.url_path
48
- end
49
-
50
- def test_all
51
- assert_equal 1, Staticpress::Content::Tag.all.count
52
- assert Staticpress::Content::Tag.all.include?(@tag_page)
53
- end
54
-
55
- def test_content_by_tag
56
- [
57
- Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '06', :title => 'in-charlotte').content
58
- ].each { |content| assert_includes Staticpress::Content::Tag.content_by_tag['charlotte'], content }
59
- end
60
- end
@@ -1,114 +0,0 @@
1
- require_relative 'base_test'
2
-
3
- require 'staticpress/content/theme'
4
- require 'staticpress/helpers'
5
- require 'staticpress/route'
6
-
7
- class ContentThemeTest < ContentBaseTest
8
- include Staticpress::Helpers
9
-
10
- def setup
11
- super
12
-
13
- config.theme = :test_theme
14
-
15
- @theme_dir = Staticpress::Theme.theme.root
16
-
17
- @asset_style_route = Staticpress::Route.from_url_path '/assets/test_theme/styles/all'
18
- @asset_style = Staticpress::Content::Theme.new @asset_style_route, @theme_dir + 'assets' + 'styles' + 'all.sass'
19
-
20
- @asset_script_route = Staticpress::Route.from_url_path '/assets/test_theme/scripts/application.js'
21
- @asset_script = Staticpress::Content::Theme.new @asset_script_route, @theme_dir + 'assets' + 'scripts' + 'application.js'
22
- end
23
-
24
- def test__equalsequals
25
- assert_operator @asset_style, :==, Staticpress::Content::Theme.new(@asset_style_route, @theme_dir + 'assets' + 'styles' + 'all.sass')
26
- refute_operator @asset_style, :==, nil
27
- end
28
-
29
- def test_all
30
- assert_equal 2, Staticpress::Content::Theme.all.count
31
- end
32
-
33
- def test_exist?
34
- assert @asset_style.exist?, '@asset_style does not exist'
35
- assert @asset_script.exist?, '@asset_script does not exist'
36
- end
37
-
38
- def test_find_by_path
39
- assert_equal @asset_style, Staticpress::Content::Theme.find_by_path(@theme_dir + 'assets' + 'styles' + 'all.sass')
40
- assert_nil Staticpress::Content::Theme.find_by_path(@theme_dir + 'i' + 'dont' + 'exist.markdown')
41
- path = (@theme_dir + 'assets' + 'scripts' + 'application.js')
42
- actual = Staticpress::Content::Theme.find_by_path(@theme_dir + 'assets' + 'scripts' + 'application.js')
43
- assert_equal @asset_script, actual
44
- end
45
-
46
- def test_find_by_route
47
- assert_equal @asset_style, Staticpress::Content::Theme.find_by_route(@asset_style_route)
48
- assert_nil Staticpress::Content::Theme.find_by_route(nil)
49
- assert_equal @asset_script, Staticpress::Content::Theme.find_by_route(@asset_script_route)
50
- end
51
-
52
- def test_inspect
53
- assert_equal '#<Staticpress::Content::Theme url_path=/assets/test_theme/styles/all>', @asset_style.inspect
54
- end
55
-
56
- def test_output_path
57
- assert_equal (Staticpress.blog_path + 'public' + 'assets' + 'test_theme' + 'styles' + 'all'), @asset_style.output_path
58
- assert_equal (Staticpress.blog_path + 'public' + 'assets' + 'test_theme' + 'scripts' + 'application.js'), @asset_script.output_path
59
- end
60
-
61
- def test_raw
62
- assert_equal '@import "compass/reset/utilities"', @asset_style.raw
63
- expected = <<-JS
64
- (function ($) {
65
- $(document).ready(function () {
66
- });
67
- })(jQuery);
68
- JS
69
- assert_equal expected.strip, @asset_script.raw
70
- end
71
-
72
- def test_render
73
- refute_raises(Sass::SyntaxError) { @asset_style.render }
74
- expected = <<-SASS
75
- SASS
76
- assert_equal expected, @asset_style.render
77
- expected = <<-JS
78
- (function ($) {
79
- $(document).ready(function () {
80
- });
81
- })(jQuery);
82
- JS
83
- assert_equal expected, @asset_script.render
84
- end
85
-
86
- def test_render_partial
87
- refute_raises(Sass::SyntaxError) { @asset_style.render_partial }
88
- expected = <<-SASS
89
- SASS
90
- assert_equal expected, @asset_style.render_partial
91
- expected = <<-JS
92
- (function ($) {
93
- $(document).ready(function () {
94
- });
95
- })(jQuery);
96
- JS
97
- assert_equal expected, @asset_script.render_partial
98
- end
99
-
100
- def test_route
101
- assert_equal '/assets/test_theme/styles/all', @asset_style.route.url_path
102
- end
103
-
104
- def test_template_engine_options
105
- expected = Compass.sass_engine_options.merge :line_comments => false, :style => :compressed
106
- assert_eql expected, @asset_style.template_engine_options
107
- assert_equal({}, @asset_script.template_engine_options)
108
- end
109
-
110
- def test_template_type
111
- assert_equal :sass, @asset_style.template_type
112
- assert_equal :js, @asset_script.template_type
113
- end
114
- end