staticpress 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/NOTES.markdown +23 -0
  2. data/Rakefile +1 -6
  3. data/docs/content/docs/plugins/pagination.haml +30 -0
  4. data/docs/content/docs/samples/page.markdown +14 -0
  5. data/docs/content/docs/samples/post.markdown +18 -0
  6. data/docs/content/docs/themes.markdown +47 -0
  7. data/lib/skeleton/config.yml +1 -0
  8. data/lib/staticpress/cli.rb +5 -9
  9. data/lib/staticpress/content/base.rb +8 -10
  10. data/lib/staticpress/content/category.rb +17 -4
  11. data/lib/staticpress/content/collection_content.rb +1 -3
  12. data/lib/staticpress/content/index.rb +6 -3
  13. data/lib/staticpress/content/page.rb +4 -0
  14. data/lib/staticpress/content/post.rb +4 -1
  15. data/lib/staticpress/content/resource_content.rb +2 -8
  16. data/lib/staticpress/content/tag.rb +17 -4
  17. data/lib/staticpress/content/theme.rb +1 -1
  18. data/lib/staticpress/helpers.rb +5 -5
  19. data/lib/staticpress/plugins/menu.rb +1 -1
  20. data/lib/staticpress/plugins/pagination.rb +38 -0
  21. data/lib/staticpress/theme.rb +45 -17
  22. data/lib/staticpress/version.rb +1 -1
  23. data/lib/themes/basic/includes/github.haml +2 -0
  24. data/lib/themes/basic/layouts/default.haml +1 -0
  25. data/lib/themes/basic/views/page_paged.haml +6 -0
  26. data/{tests → spec/fixtures}/test_blog/Gemfile +0 -0
  27. data/{tests → spec/fixtures}/test_blog/README.markdown +0 -0
  28. data/{tests → spec/fixtures}/test_blog/config.ru +0 -0
  29. data/{tests → spec/fixtures}/test_blog/config.yml +0 -0
  30. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-07-20-hello.markdown +0 -0
  31. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-01-announcing-staticpress.markdown +0 -0
  32. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-02-staticpress.markdown +0 -0
  33. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-blogging-with-staticpress.markdown +0 -0
  34. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-conferences.markdown +0 -0
  35. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-in-charlotte.markdown +0 -0
  36. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-20-forever.markdown +0 -0
  37. data/{tests → spec/fixtures}/test_blog/content/_posts/2012-09-19-unpublished.markdown +0 -0
  38. data/{tests → spec/fixtures}/test_blog/content/about.markdown +0 -0
  39. data/{tests → spec/fixtures}/test_blog/content/chain.html.markdown.erb +0 -0
  40. data/{tests → spec/fixtures}/test_blog/content/chained.markdown.erb +0 -0
  41. data/{tests → spec/fixtures}/test_blog/content/contact.markdown +0 -0
  42. data/{tests → spec/fixtures}/test_blog/content/foo/bar/baz.markdown +0 -0
  43. data/{tests → spec/fixtures}/test_blog/content/index.markdown +0 -0
  44. data/{tests → spec/fixtures}/test_blog/content/plain.txt +0 -0
  45. data/{tests → spec/fixtures}/test_blog/content/ruby.png +0 -0
  46. data/{tests → spec/fixtures}/test_blog/content/style1.css +0 -0
  47. data/{tests → spec/fixtures}/test_blog/content/style2.css.sass +0 -0
  48. data/{tests → spec/fixtures}/test_blog/content/style3.sass +0 -0
  49. data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/scripts/application.js +0 -0
  50. data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/styles/all.sass +0 -0
  51. data/{tests → spec/fixtures}/test_blog/themes/test_theme/includes/list_posts.haml +0 -0
  52. data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/archive.haml +0 -0
  53. data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/atom.haml +0 -0
  54. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/default.haml +0 -0
  55. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/index.haml +0 -0
  56. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/post_index.haml +0 -0
  57. data/{tests → spec/fixtures}/test_blog/themes/test_theme/views/default.haml +0 -0
  58. data/spec/integration/editing_blog_contents_spec.rb +52 -0
  59. data/spec/integration/editing_blog_spec.rb +42 -0
  60. data/spec/integration/getting_started_spec.rb +29 -0
  61. data/spec/spec_helper.rb +35 -0
  62. data/spec/support/custom_matchers.rb +15 -0
  63. data/spec/support/fixtures.rb +35 -0
  64. data/spec/support/integration_support.rb +230 -0
  65. data/spec/support/unit_support.rb +18 -0
  66. data/spec/unit/staticpress/content/base_spec.rb +327 -0
  67. data/spec/unit/staticpress/content/category_spec.rb +60 -0
  68. data/spec/unit/staticpress/content/index_spec.rb +48 -0
  69. data/spec/unit/staticpress/content/page_spec.rb +70 -0
  70. data/spec/unit/staticpress/content/post_spec.rb +54 -0
  71. data/spec/unit/staticpress/content/resource_content_spec.rb +21 -0
  72. data/spec/unit/staticpress/content/tag_spec.rb +53 -0
  73. data/spec/unit/staticpress/content/theme_spec.rb +31 -0
  74. data/spec/unit/staticpress/helpers_spec.rb +72 -0
  75. data/spec/unit/staticpress/js_object_spec.rb +61 -0
  76. data/spec/unit/staticpress/metadata_spec.rb +15 -0
  77. data/spec/unit/staticpress/route_spec.rb +219 -0
  78. data/spec/unit/staticpress/server_spec.rb +23 -0
  79. data/spec/unit/staticpress/settings_spec.rb +19 -0
  80. data/spec/unit/staticpress/site_spec.rb +26 -0
  81. data/spec/unit/staticpress/theme_spec.rb +80 -0
  82. data/spec/unit/staticpress/view_helpers_spec.rb +40 -0
  83. data/spec/unit/staticpress_spec.rb +27 -0
  84. data/staticpress.gemspec +3 -4
  85. metadata +133 -136
  86. data/features/editing_blog.feature +0 -24
  87. data/features/editing_blog_contents.feature +0 -40
  88. data/features/getting_started.feature +0 -17
  89. data/features/step_definitions/editing_blog_contents_steps.rb +0 -128
  90. data/features/step_definitions/editing_blog_steps.rb +0 -52
  91. data/features/step_definitions/getting_started_steps.rb +0 -51
  92. data/features/support/env.rb +0 -30
  93. data/lib/themes/basic/layouts/post_index.haml +0 -15
  94. data/lib/themes/basic/views/default.haml +0 -10
  95. data/tests/staticpress/configuration_test.rb +0 -4
  96. data/tests/staticpress/content/base_test.rb +0 -291
  97. data/tests/staticpress/content/category_test.rb +0 -48
  98. data/tests/staticpress/content/index_test.rb +0 -40
  99. data/tests/staticpress/content/page_test.rb +0 -56
  100. data/tests/staticpress/content/post_test.rb +0 -42
  101. data/tests/staticpress/content/resource_content_test.rb +0 -17
  102. data/tests/staticpress/content/tag_test.rb +0 -39
  103. data/tests/staticpress/content/theme_test.rb +0 -26
  104. data/tests/staticpress/helpers_test.rb +0 -63
  105. data/tests/staticpress/js_object_test.rb +0 -47
  106. data/tests/staticpress/metadata_test.rb +0 -14
  107. data/tests/staticpress/plugin_test.rb +0 -4
  108. data/tests/staticpress/pusher_test.rb +0 -9
  109. data/tests/staticpress/route_test.rb +0 -186
  110. data/tests/staticpress/server_test.rb +0 -17
  111. data/tests/staticpress/settings_test.rb +0 -13
  112. data/tests/staticpress/site_test.rb +0 -20
  113. data/tests/staticpress/theme_test.rb +0 -83
  114. data/tests/staticpress/view_helpers_test.rb +0 -32
  115. data/tests/staticpress_test.rb +0 -18
  116. data/tests/test_blog/themes/test_theme/layouts/archive.haml +0 -0
  117. data/tests/test_blog/themes/test_theme/layouts/atom.haml +0 -0
  118. data/tests/test_case.rb +0 -54
@@ -1,24 +0,0 @@
1
- Feature: Editing blog
2
-
3
- Background:
4
- Given a blog exists
5
-
6
- Scenario: Creating a new blog post
7
- When I create a new post
8
- Then I can edit the post
9
-
10
- Scenario: Creating a static page
11
- When I create a new page
12
- Then I can edit the page
13
-
14
- Scenario: Copying a built-in plugin
15
- When I fork a plugin
16
- Then I can edit the forked plugin
17
-
18
- Scenario: Copying and renaming a built-in plugin
19
- When I fork and rename a plugin
20
- Then I can edit my plugin
21
-
22
- Scenario: Copying the default theme
23
- When I fork the default theme
24
- Then I can edit the theme files
@@ -1,40 +0,0 @@
1
- Feature: Editing blog contents
2
-
3
- Background:
4
- Given a blog with content exists
5
-
6
- Scenario: Creating a static page with multiple formats
7
- When I create a simple page with multiple formats
8
- And build the site
9
- Then the formats page only contains markup
10
-
11
- Scenario: Listing all routes
12
- When I list my blog's URLs
13
- Then the static pages are present
14
-
15
- Scenario: Building a site
16
- Then the output directory does not exist
17
- When I build the site
18
- Then the output directory contains some markup files
19
-
20
- Scenario: Building a site (verbose)
21
- When I build the site verbosely
22
- Then I see each output file
23
-
24
- Scenario: Building a site with a custom homepage
25
- When I create a custom home page
26
- And I build the site
27
- Then the build homepage looks good
28
-
29
- Scenario: Pushing a compiled site to a remote location
30
- Given I build the site
31
- When I add a custom deployment strategy
32
- And push the site
33
- Then the site is deployed
34
-
35
- Scenario: Deploying site (build and push in one step)
36
- Given I add a custom deployment strategy
37
- And the site is not built or deployed
38
- When I deploy the site
39
- Then the output directory contains some markup files
40
- And the site is deployed
@@ -1,17 +0,0 @@
1
- Feature: Getting started
2
-
3
- Scenario: Getting help
4
- Given I ask for help
5
- Then I am pointed in the right direction
6
-
7
- Scenario: Finding the version
8
- Given I want Staticpress' version
9
- Then I see the version
10
-
11
- Scenario: Creating a new blog
12
- When I make a new blog
13
- Then the minimal files are present
14
-
15
- Scenario: Creating a new blog with a custum title
16
- When I make a new blog called "This is my blog"
17
- Then Staticpress should remember my blog title
@@ -1,128 +0,0 @@
1
- Given /^a blog with content exists$/ do
2
- create_sample_blog
3
- run_simple 'staticpress create_page about'
4
- run_simple 'staticpress create hello-goodbye'
5
- end
6
-
7
- Given /^the site is not built or deployed$/ do
8
- files = [
9
- 'public/index.html',
10
- 'public/about/index.html',
11
- '../deployed/index.html',
12
- '../deployed/about/index.html'
13
- ]
14
- check_file_presence files, false
15
- end
16
-
17
-
18
- When /^I create a simple page with multiple formats$/ do
19
- write_file 'content/formats.markdown.erb', 'hello world'
20
- end
21
-
22
- When /^(I )?(\w+) the site$/ do |ignored, action|
23
- run_simple "staticpress #{action}"
24
- end
25
-
26
- When /^I list my blog's URLs$/ do
27
- run_simple 'staticpress list url_path'
28
- end
29
-
30
- When /^I build the site verbosely$/ do
31
- run_simple 'staticpress build --verbose'
32
- end
33
-
34
- When /^I create a custom home page$/ do
35
- write_file 'content/index.markdown', <<-MARKDOWN
36
- ---
37
- title: Custom Home Page
38
- ---
39
-
40
- in custom page
41
- MARKDOWN
42
- end
43
-
44
- When /^I add a custom deployment strategy$/ do
45
- append_to_file 'config.yml', <<-YAML
46
- :deployment_strategies:
47
- :custom: 'cp -R public ../deployed'
48
- YAML
49
- end
50
-
51
-
52
- Then /^the formats page only contains markup$/ do
53
- check_exact_file_content 'public/formats/index.html', <<-HTML
54
- <!DOCTYPE html>
55
- <html>
56
- <head>
57
- <meta charset='utf-8' />
58
- <title>Formats | Transient Thoughts</title>
59
- <link href='/assets/basic/styles/all.css' rel='stylesheet' type='text/css' />
60
- <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js'></script>
61
- <script src='/assets/basic/scripts/application.js'></script>
62
- </head>
63
- <body>
64
- <header>
65
- <div class='site-title'>Transient Thoughts</div>
66
- <div class='site-subtitle'>A blogging framework for hackers</div>
67
- </header>
68
- <nav></nav>
69
- <section><p>hello world</p></section>
70
- <section></section>
71
- </body>
72
- </html>
73
- HTML
74
- end
75
-
76
- Then /^the static pages are present$/ do
77
- assert_partial_output '/', all_output
78
- assert_partial_output '/about', all_output
79
- assert_partial_output '/hello-goodbye', all_output
80
- end
81
-
82
- Then /^the output directory does not exist$/ do
83
- check_directory_presence ['public'], false
84
- end
85
-
86
- Then /^the output directory contains some markup files$/ do
87
- files = [
88
- 'public/index.html',
89
- 'public/about/index.html'
90
- ]
91
- check_file_presence files, true
92
- end
93
-
94
- Then /^I see each output file$/ do
95
- assert_partial_output " page public/about/index.html", all_output
96
- end
97
-
98
- Then /^the build homepage looks good$/ do
99
- check_exact_file_content 'public/index.html', <<-HTML
100
- <!DOCTYPE html>
101
- <html>
102
- <head>
103
- <meta charset='utf-8' />
104
- <title>Custom Home Page | Transient Thoughts</title>
105
- <link href='/assets/basic/styles/all.css' rel='stylesheet' type='text/css' />
106
- <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js'></script>
107
- <script src='/assets/basic/scripts/application.js'></script>
108
- </head>
109
- <body>
110
- <header>
111
- <div class='site-title'>Transient Thoughts</div>
112
- <div class='site-subtitle'>A blogging framework for hackers</div>
113
- </header>
114
- <nav></nav>
115
- <section><p>in custom page</p></section>
116
- <section></section>
117
- </body>
118
- </html>
119
- HTML
120
- end
121
-
122
- Then /^the site is deployed$/ do
123
- files = [
124
- '../deployed/index.html',
125
- '../deployed/about/index.html'
126
- ]
127
- check_file_presence files, true
128
- end
@@ -1,52 +0,0 @@
1
- Given /^a blog exists$/ do
2
- create_sample_blog
3
- end
4
-
5
-
6
- When /^I create a new post$/ do
7
- run_simple 'staticpress create \'Hello World\''
8
- end
9
-
10
- When /^I create a new page$/ do
11
- run_simple 'staticpress create_page about'
12
- end
13
-
14
- When /^I fork a plugin$/ do
15
- run_simple 'staticpress fork_plugin blockquote'
16
- end
17
-
18
- When /^I fork and rename a plugin$/ do
19
- run_simple 'staticpress fork_plugin blockquote pullquote'
20
- end
21
-
22
- When /^I fork the default theme$/ do
23
- run_simple 'staticpress fork_theme'
24
- end
25
-
26
-
27
- Then /^I can edit the post$/ do
28
- now = Time.now.utc
29
- filename = [
30
- now.year,
31
- ('%02d' % now.month),
32
- ('%02d' % now.day),
33
- 'hello-world.markdown'
34
- ].join('-')
35
- verify_directory_contains_file 'content/_posts', filename
36
- end
37
-
38
- Then /^I can edit the page$/ do
39
- verify_directory_contains_file 'content', 'about.markdown'
40
- end
41
-
42
- Then /^I can edit the forked plugin$/ do
43
- verify_directory_contains_file 'plugins', 'blockquote.rb'
44
- end
45
-
46
- Then /^I can edit my plugin$/ do
47
- verify_directory_contains_file 'plugins', 'pullquote.rb'
48
- end
49
-
50
- Then /^I can edit the theme files$/ do
51
- check_directory_presence ['themes/basic'], true
52
- end
@@ -1,51 +0,0 @@
1
- Given /^I ask for help$/ do
2
- commands = [
3
- 'staticpress',
4
- 'staticpress help',
5
- 'staticpress -h',
6
- 'staticpress --help'
7
- ]
8
- run_one_of *commands
9
- end
10
-
11
- Given /^I want Staticpress' version$/ do
12
- commands = [
13
- 'staticpress version',
14
- 'staticpress -v',
15
- 'staticpress --version'
16
- ]
17
- run_one_of *commands
18
- end
19
-
20
-
21
- When /^I make a new blog( called "(.+)")?$/ do |ignored, title|
22
- create_sample_blog title
23
- end
24
-
25
-
26
- Then /^I am pointed in the right direction$/ do
27
- assert_exit_status 0
28
- assert_partial_output 'Usage', all_output
29
- end
30
-
31
- Then /^I see the version$/ do
32
- assert_exit_status 0
33
- assert_partial_output 'Staticpress', all_output
34
- end
35
-
36
- Then /^the minimal files are present$/ do
37
- files = [
38
- 'config.ru',
39
- 'config.yml',
40
- 'Gemfile',
41
- 'README.markdown'
42
- ]
43
- check_file_presence files, true
44
- end
45
-
46
- Then /^Staticpress should remember my blog title$/ do
47
- check_file_content 'config.yml', <<-YAML, true
48
- ---
49
- :title: This is my blog
50
- YAML
51
- end
@@ -1,30 +0,0 @@
1
- require 'aruba/cucumber'
2
-
3
- require 'compass'
4
- require 'debugger'
5
- require 'haml'
6
- require 'redcarpet'
7
- require 'sass'
8
-
9
- require_relative '../../lib/staticpress'
10
-
11
- module IntegrationHelpers
12
- def create_sample_blog(title = 'Transient Thoughts')
13
- blog_title = title ? "'#{title}'" : nil
14
- run_simple "staticpress new temporary_blog #{blog_title}"
15
- cd('temporary_blog')
16
- append_to_file 'Gemfile', <<-RUBY
17
- gem 'staticpress', :path => '../../..'
18
- RUBY
19
- end
20
-
21
- def run_one_of(*commands)
22
- run_simple commands.shuffle.first
23
- end
24
-
25
- def verify_directory_contains_file(directory, file)
26
- check_directory_presence [directory], true
27
- check_file_presence ["#{directory}/#{file}"], true
28
- end
29
- end
30
- World IntegrationHelpers
@@ -1,15 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- %meta{ :charset => 'utf-8' }/
5
- %title= page.full_title
6
- %link{ :rel => :stylesheet, :href => '/assets/basic/styles/all.css', :type => 'text/css' }/
7
- %script{ :src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js' }
8
- %script{ :src => '/assets/basic/scripts/application.js' }
9
- %body
10
- %header
11
- %div.site-title= config.title
12
- %div.site-subtitle= config.subtitle
13
- %nav= root_menu
14
- %section= yield
15
- %section
@@ -1,10 +0,0 @@
1
- ---
2
- layout: post_index
3
- ---
4
-
5
- %section
6
- - page.sub_content.each do |post|
7
- %article.post
8
- %header
9
- %div.h= post.title
10
- %section= post.render_partial
@@ -1,4 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class ConfigurationTest < TestCase
4
- end
@@ -1,291 +0,0 @@
1
- require_relative '../../test_case'
2
-
3
- class ContentBaseTest < TestCase
4
- let(:category) { Staticpress::Content::Category.new :name => 'programming' }
5
- let(:category_1) { Staticpress::Content::Category.new(:name => 'programming', :number => '1') }
6
- let(:category_2) { Staticpress::Content::Category.new(:name => 'programming', :number => '2') }
7
-
8
- let(:index) { Staticpress::Content::Index.new }
9
- let(:index_2) { Staticpress::Content::Index.new :number => 2 }
10
-
11
- let(:chained) { Staticpress::Content::Page.new(:slug => 'chained') }
12
- let(:chain) { Staticpress::Content::Page.new(:slug => 'chain.html') }
13
- let(:page) { Staticpress::Content::Page.new(:slug => 'about') }
14
- let(:second_page) { Staticpress::Content::Page.new :slug => 'contact' }
15
- let(:page_root) { Staticpress::Content::Page.new :slug => '' }
16
- let(:style_2) { Staticpress::Content::Page.new :slug => 'style2.css' }
17
- let(:page_nested) { Staticpress::Content::Page.new :slug => 'foo/bar/baz' }
18
- let(:static_bin) { Staticpress::Content::Page.new :slug => 'ruby.png' }
19
- let(:static_txt) { Staticpress::Content::Page.new :slug => 'plain.txt' }
20
- let(:page_fake) { Staticpress::Content::Page.new :slug => 'i/dont/exist' }
21
-
22
- let(:post) { Staticpress::Content::Post.new(:year => '2011', :month => '07', :day => '20', :title => 'hello') }
23
- let(:unpublished) { Staticpress::Content::Post.new(:year => '2012', :month => '09', :day => '19', :title => 'unpublished') }
24
-
25
- let(:tag) { Staticpress::Content::Tag.new :name => 'charlotte' }
26
-
27
- let(:asset_style) { Staticpress::Content::Theme.new :theme => 'test_theme', :asset_type => 'styles', :slug => 'all' }
28
- let(:asset_script) { Staticpress::Content::Theme.new :theme => 'test_theme', :asset_type => 'scripts', :slug => 'application.js' }
29
-
30
- def test__equalsequals
31
- assert_operator category, :==, Staticpress::Content::Category.new(:name => 'programming')
32
- refute_operator category, :==, nil
33
-
34
- assert_operator index, :==, Staticpress::Content::Index.new(:number => 1)
35
- refute_operator index, :==, index_2
36
- refute_operator index, :==, nil
37
-
38
- assert_operator page, :==, Staticpress::Content::Page.new(:slug => 'about')
39
- refute_operator page, :==, second_page
40
- refute_operator page, :==, nil
41
- assert_operator static_bin, :==, Staticpress::Content::Page.new(:slug => 'ruby.png')
42
- refute_operator static_bin, :==, nil
43
- refute_operator static_bin, :==, static_txt
44
-
45
- assert_operator post, :==, Staticpress::Content::Post.new(:year => '2011', :month => '07', :day => '20', :title => 'hello')
46
- refute_operator post, :==, nil
47
-
48
- assert_operator tag, :==, Staticpress::Content::Tag.new(:name => 'charlotte')
49
- refute_operator tag, :==, nil
50
-
51
- assert_operator asset_style, :==, Staticpress::Content::Theme.new(:theme => 'test_theme', :asset_type => 'styles', :slug => 'all')
52
- refute_operator asset_style, :==, nil
53
-
54
- refute_operator Staticpress::Content::Category.new(:name => 'programming'), :==, Staticpress::Content::Tag.new(:name => 'programming')
55
- refute_operator Staticpress::Content::Tag.new(:name => 'charlotte'), :==, Staticpress::Content::Category.new(:name => 'charlotte')
56
- end
57
-
58
- def test_content_type
59
- assert_equal 'text/html', chained.content_type
60
- assert_equal 'text/html', page.content_type
61
- assert_equal 'text/css', style_2.content_type
62
- assert_equal 'image/png', static_bin.content_type
63
- assert_equal 'text/plain', static_txt.content_type
64
- end
65
-
66
- def test_exist?
67
- assert category.exist?, "#{category} does not exist"
68
- assert index.exist?, "#{index} does not exist"
69
-
70
- assert chained.exist?, "#{chained} does not exist"
71
- assert chain.exist?, "#{chain} does not exist"
72
- assert page.exist?, "#{page} does not exist"
73
- assert second_page.exist?, "#{second_page} does not exist"
74
- assert static_bin.exist?, "#{static_bin} does not exist"
75
- assert static_txt.exist?, "#{static_txt} does not exist"
76
- assert page_root.exist?, "#{page_root} does not exist"
77
-
78
- assert post.exist?, "#{post} does not exist"
79
- assert unpublished.exist?, "#{unpublished} does not exist"
80
- assert tag.exist?, "#{tag} does not exist"
81
-
82
- assert asset_style.exist?, "#{asset_style} does not exist"
83
- assert asset_script.exist?, "#{asset_script} does not exist"
84
-
85
- refute page_fake.exist?, "#{page_fake} exists"
86
- end
87
-
88
- def test_find_by_url_path
89
- assert_equal category, Staticpress::Content::Category.find_by_url_path('/category/programming')
90
- assert_equal index, Staticpress::Content::Index.find_by_url_path('/')
91
-
92
- assert_equal page_root, Staticpress::Content::Page.find_by_url_path('/')
93
- assert_equal chained, Staticpress::Content::Page.find_by_url_path('/chained')
94
- assert_equal page, Staticpress::Content::Page.find_by_url_path('/about')
95
- assert_equal static_bin, Staticpress::Content::Page.find_by_url_path('/ruby.png')
96
-
97
- assert_equal post, Staticpress::Content::Post.find_by_url_path('/2011/07/20/hello')
98
- assert_equal tag, Staticpress::Content::Tag.find_by_url_path('/tag/charlotte')
99
-
100
- assert_equal asset_style, Staticpress::Content::Theme.find_by_url_path('/assets/test_theme/styles/all')
101
- assert_equal asset_script, Staticpress::Content::Theme.find_by_url_path('/assets/test_theme/scripts/application.js')
102
-
103
- assert_nil Staticpress::Content::Theme.find_by_url_path(nil)
104
- end
105
-
106
- def test_full_title
107
- assert_equal 'Foo -> Bar -> Baz | Test Blog', page_nested.full_title
108
- end
109
-
110
- def test_markup_template?
111
- assert chained.markup_template?, "#{chained} is not markup"
112
- assert chain.markup_template?, "#{chain} is not markup"
113
- assert page.markup_template?, "#{page} is not markup"
114
-
115
- refute style_2.markup_template?, "#{chained} is markup"
116
- end
117
-
118
- def test_output_path
119
- output_directory = Staticpress.blog_path + 'public'
120
- assert_equal (output_directory + 'chained' + 'index.html'), chained.output_path
121
- assert_equal (output_directory + 'chain.html'), chain.output_path
122
- assert_equal (output_directory + 'about' + 'index.html'), page.output_path
123
- assert_equal (output_directory + 'index.html'), page_root.output_path
124
- assert_equal (output_directory + 'style2.css'), style_2.output_path
125
- assert_equal (output_directory + 'ruby.png'), static_bin.output_path
126
- assert_equal (output_directory + 'plain.txt'), static_txt.output_path
127
- assert_equal (output_directory + '2011' + '07' + '20' + 'hello' + 'index.html'), post.output_path
128
- assert_equal (output_directory + 'assets' + 'test_theme' + 'styles' + 'all'), asset_style.output_path
129
- assert_equal (output_directory + 'assets' + 'test_theme' + 'scripts' + 'application.js'), asset_script.output_path
130
- end
131
-
132
- def test_params
133
- expected = { :name => 'charlotte', :number => 1 }
134
- assert_equal expected, tag.params
135
- assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => nil).params
136
- assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => 1).params
137
- assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => '1').params
138
-
139
- assert_equal({ :slug => 'chain.html' }, Staticpress::Content::Page.new(:slug => 'chain.html').params)
140
- end
141
-
142
- def test_raw
143
- assert_equal '= partial :list_posts, :posts => page.sub_content', category.raw
144
-
145
- assert_equal "<%= 'Processed with ERB' %>, then Markdown.", chained.raw
146
- assert_equal 'in page', page.raw
147
- assert_equal "in page\n\nin page", second_page.raw
148
- assert_equal 'this file intentionally left blank', static_txt.raw
149
-
150
- assert_equal 'in post', post.raw
151
- assert_equal '= partial :list_posts, :posts => page.sub_content', tag.raw
152
- assert_equal '@import "compass/reset/utilities"', asset_style.raw
153
-
154
- expected = <<-JS
155
- (function ($) {
156
- $(document).ready(function () {
157
- });
158
- })(jQuery);
159
- JS
160
- assert_equal expected.strip, asset_script.raw
161
- end
162
-
163
- def test_render
164
- expected_page = <<-HTML
165
- <!DOCTYPE html>
166
- <html>
167
- <head>
168
- <title>About | Test Blog</title>
169
- </head>
170
- <body>
171
- <p>in page</p>
172
- </body>
173
- </html>
174
- HTML
175
- assert_equal expected_page, page.render
176
-
177
- expected_style2 = <<-CSS
178
- body{color:green}
179
- CSS
180
- assert_equal expected_style2, style_2.render
181
-
182
- assert_equal 'this file intentionally left blank', static_txt.render
183
- refute_raises(Sass::SyntaxError) { asset_style.render }
184
-
185
- expected = <<-SASS
186
- SASS
187
- assert_equal expected, asset_style.render
188
-
189
- expected = <<-JS
190
- (function ($) {
191
- $(document).ready(function () {
192
- });
193
- })(jQuery);
194
- JS
195
- assert_equal expected, asset_script.render
196
- end
197
-
198
- def test_render_partial
199
- assert_equal "<p>Processed with ERB, then Markdown.</p>\n", chained.render_partial
200
- assert_equal "<p>in page</p>\n", page.render_partial
201
- assert_equal "<p>in page</p>\n\n<p>in page</p>\n", second_page.render_partial
202
-
203
- expected_style2 = <<-CSS
204
- body{color:green}
205
- CSS
206
- assert_equal expected_style2, style_2.render_partial
207
-
208
- assert_equal 'this file intentionally left blank', static_txt.render_partial
209
- assert_equal "<p>in post</p>\n", post.render_partial
210
-
211
- refute_raises(Sass::SyntaxError) { asset_style.render_partial }
212
- expected = <<-SASS
213
- SASS
214
-
215
- assert_equal expected, asset_style.render_partial
216
- expected = <<-JS
217
- (function ($) {
218
- $(document).ready(function () {
219
- });
220
- })(jQuery);
221
- JS
222
- assert_equal expected, asset_script.render_partial
223
- end
224
-
225
- def test_save
226
- static_bin.save
227
- assert_equal static_bin.template_path.binread, static_bin.output_path.binread
228
-
229
- static_txt.save
230
- assert_equal static_txt.template_path.read, static_txt.output_path.read
231
- end
232
-
233
- def test_template_engine_options
234
- refute asset_script.template_engine_options(:sass)[:line_comments]
235
- assert_equal :compressed, asset_script.template_engine_options(:sass)[:style]
236
- assert_equal({}, asset_script.template_engine_options(:js))
237
- end
238
-
239
- def test_template_types
240
- assert_equal [:erb, :markdown], chained.template_types
241
- assert_equal [:erb, :markdown], chain.template_types
242
- assert_equal [:markdown], page.template_types
243
- assert_equal [:sass], asset_style.template_types
244
- assert_equal [], asset_script.template_types
245
- end
246
-
247
- def test_title
248
- assert_equal 'Foo -> Bar -> Baz', page_nested.title
249
- end
250
-
251
- def test_to_s
252
- assert_equal '#<Staticpress::Content::Category url_path=/category/programming, params={:name=>"programming", :number=>1}>', category.to_s
253
- assert_equal '#<Staticpress::Content::Category url_path=/category/programming, params={:name=>"programming", :number=>1}>', Staticpress::Content::Category.new(:name => 'programming', :number => nil).to_s
254
-
255
- assert_equal '#<Staticpress::Content::Index url_path=/, params={:number=>1}>', index.to_s
256
- assert_equal '#<Staticpress::Content::Index url_path=/page/2, params={:number=>2}>', index_2.to_s
257
-
258
- assert_equal '#<Staticpress::Content::Page url_path=/, params={:slug=>""}>', page_root.to_s
259
- assert_equal '#<Staticpress::Content::Page url_path=/about, params={:slug=>"about"}>', page.to_s
260
- assert_equal '#<Staticpress::Content::Page url_path=/ruby.png, params={:slug=>"ruby.png"}>', static_bin.to_s
261
-
262
- assert_equal '#<Staticpress::Content::Post url_path=/2011/07/20/hello, params={:day=>"20", :month=>"07", :title=>"hello", :year=>"2011"}>', post.to_s
263
-
264
- assert_equal '#<Staticpress::Content::Tag url_path=/tag/charlotte, params={:name=>"charlotte", :number=>1}>', tag.to_s
265
-
266
- assert_equal '#<Staticpress::Content::Theme url_path=/assets/test_theme/styles/all, params={:asset_type=>"styles", :slug=>"all", :theme=>"test_theme"}>', asset_style.to_s
267
- end
268
-
269
- def test_url_path
270
- assert_equal '/category/programming', category.url_path
271
- assert_equal '/category/programming', category_1.url_path
272
- assert_equal '/category/programming/page/2', category_2.url_path
273
-
274
- assert_equal '/', index.url_path
275
- assert_equal '/page/2', index_2.url_path
276
-
277
- assert_equal '/', page_root.url_path
278
- assert_equal '/chained', chained.url_path
279
- assert_equal '/chain.html', chain.url_path
280
- assert_equal '/about', page.url_path
281
- assert_equal '/contact', second_page.url_path
282
- assert_equal '/ruby.png', static_bin.url_path
283
- assert_equal '/plain.txt', static_txt.url_path
284
-
285
- assert_equal '/2011/07/20/hello', post.url_path
286
-
287
- assert_equal '/2011/07/20/hello', post.url_path
288
- assert_equal '/tag/charlotte', tag.url_path
289
- assert_equal '/assets/test_theme/styles/all', asset_style.url_path
290
- end
291
- end