staticpress 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTES.markdown +23 -0
- data/Rakefile +1 -6
- data/docs/content/docs/plugins/pagination.haml +30 -0
- data/docs/content/docs/samples/page.markdown +14 -0
- data/docs/content/docs/samples/post.markdown +18 -0
- data/docs/content/docs/themes.markdown +47 -0
- data/lib/skeleton/config.yml +1 -0
- data/lib/staticpress/cli.rb +5 -9
- data/lib/staticpress/content/base.rb +8 -10
- data/lib/staticpress/content/category.rb +17 -4
- data/lib/staticpress/content/collection_content.rb +1 -3
- data/lib/staticpress/content/index.rb +6 -3
- data/lib/staticpress/content/page.rb +4 -0
- data/lib/staticpress/content/post.rb +4 -1
- data/lib/staticpress/content/resource_content.rb +2 -8
- data/lib/staticpress/content/tag.rb +17 -4
- data/lib/staticpress/content/theme.rb +1 -1
- data/lib/staticpress/helpers.rb +5 -5
- data/lib/staticpress/plugins/menu.rb +1 -1
- data/lib/staticpress/plugins/pagination.rb +38 -0
- data/lib/staticpress/theme.rb +45 -17
- data/lib/staticpress/version.rb +1 -1
- data/lib/themes/basic/includes/github.haml +2 -0
- data/lib/themes/basic/layouts/default.haml +1 -0
- data/lib/themes/basic/views/page_paged.haml +6 -0
- data/{tests → spec/fixtures}/test_blog/Gemfile +0 -0
- data/{tests → spec/fixtures}/test_blog/README.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/config.ru +0 -0
- data/{tests → spec/fixtures}/test_blog/config.yml +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-07-20-hello.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-01-announcing-staticpress.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-02-staticpress.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-blogging-with-staticpress.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-conferences.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-in-charlotte.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-20-forever.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/_posts/2012-09-19-unpublished.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/about.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/chain.html.markdown.erb +0 -0
- data/{tests → spec/fixtures}/test_blog/content/chained.markdown.erb +0 -0
- data/{tests → spec/fixtures}/test_blog/content/contact.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/foo/bar/baz.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/index.markdown +0 -0
- data/{tests → spec/fixtures}/test_blog/content/plain.txt +0 -0
- data/{tests → spec/fixtures}/test_blog/content/ruby.png +0 -0
- data/{tests → spec/fixtures}/test_blog/content/style1.css +0 -0
- data/{tests → spec/fixtures}/test_blog/content/style2.css.sass +0 -0
- data/{tests → spec/fixtures}/test_blog/content/style3.sass +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/scripts/application.js +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/styles/all.sass +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/includes/list_posts.haml +0 -0
- data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/archive.haml +0 -0
- data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/atom.haml +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/default.haml +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/index.haml +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/post_index.haml +0 -0
- data/{tests → spec/fixtures}/test_blog/themes/test_theme/views/default.haml +0 -0
- data/spec/integration/editing_blog_contents_spec.rb +52 -0
- data/spec/integration/editing_blog_spec.rb +42 -0
- data/spec/integration/getting_started_spec.rb +29 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/custom_matchers.rb +15 -0
- data/spec/support/fixtures.rb +35 -0
- data/spec/support/integration_support.rb +230 -0
- data/spec/support/unit_support.rb +18 -0
- data/spec/unit/staticpress/content/base_spec.rb +327 -0
- data/spec/unit/staticpress/content/category_spec.rb +60 -0
- data/spec/unit/staticpress/content/index_spec.rb +48 -0
- data/spec/unit/staticpress/content/page_spec.rb +70 -0
- data/spec/unit/staticpress/content/post_spec.rb +54 -0
- data/spec/unit/staticpress/content/resource_content_spec.rb +21 -0
- data/spec/unit/staticpress/content/tag_spec.rb +53 -0
- data/spec/unit/staticpress/content/theme_spec.rb +31 -0
- data/spec/unit/staticpress/helpers_spec.rb +72 -0
- data/spec/unit/staticpress/js_object_spec.rb +61 -0
- data/spec/unit/staticpress/metadata_spec.rb +15 -0
- data/spec/unit/staticpress/route_spec.rb +219 -0
- data/spec/unit/staticpress/server_spec.rb +23 -0
- data/spec/unit/staticpress/settings_spec.rb +19 -0
- data/spec/unit/staticpress/site_spec.rb +26 -0
- data/spec/unit/staticpress/theme_spec.rb +80 -0
- data/spec/unit/staticpress/view_helpers_spec.rb +40 -0
- data/spec/unit/staticpress_spec.rb +27 -0
- data/staticpress.gemspec +3 -4
- metadata +133 -136
- data/features/editing_blog.feature +0 -24
- data/features/editing_blog_contents.feature +0 -40
- data/features/getting_started.feature +0 -17
- data/features/step_definitions/editing_blog_contents_steps.rb +0 -128
- data/features/step_definitions/editing_blog_steps.rb +0 -52
- data/features/step_definitions/getting_started_steps.rb +0 -51
- data/features/support/env.rb +0 -30
- data/lib/themes/basic/layouts/post_index.haml +0 -15
- data/lib/themes/basic/views/default.haml +0 -10
- data/tests/staticpress/configuration_test.rb +0 -4
- data/tests/staticpress/content/base_test.rb +0 -291
- data/tests/staticpress/content/category_test.rb +0 -48
- data/tests/staticpress/content/index_test.rb +0 -40
- data/tests/staticpress/content/page_test.rb +0 -56
- data/tests/staticpress/content/post_test.rb +0 -42
- data/tests/staticpress/content/resource_content_test.rb +0 -17
- data/tests/staticpress/content/tag_test.rb +0 -39
- data/tests/staticpress/content/theme_test.rb +0 -26
- data/tests/staticpress/helpers_test.rb +0 -63
- data/tests/staticpress/js_object_test.rb +0 -47
- data/tests/staticpress/metadata_test.rb +0 -14
- data/tests/staticpress/plugin_test.rb +0 -4
- data/tests/staticpress/pusher_test.rb +0 -9
- data/tests/staticpress/route_test.rb +0 -186
- data/tests/staticpress/server_test.rb +0 -17
- data/tests/staticpress/settings_test.rb +0 -13
- data/tests/staticpress/site_test.rb +0 -20
- data/tests/staticpress/theme_test.rb +0 -83
- data/tests/staticpress/view_helpers_test.rb +0 -32
- data/tests/staticpress_test.rb +0 -18
- data/tests/test_blog/themes/test_theme/layouts/archive.haml +0 -0
- data/tests/test_blog/themes/test_theme/layouts/atom.haml +0 -0
- data/tests/test_case.rb +0 -54
@@ -0,0 +1,327 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Staticpress::Content::Base do
|
4
|
+
basic_blog
|
5
|
+
|
6
|
+
let(:category) { Staticpress::Content::Category.new :name => 'programming' }
|
7
|
+
let(:category_1) { Staticpress::Content::Category.new(:name => 'programming', :number => '1') }
|
8
|
+
let(:category_2) { Staticpress::Content::Category.new(:name => 'programming', :number => '2') }
|
9
|
+
|
10
|
+
let(:index) { Staticpress::Content::Index.new }
|
11
|
+
let(:index_2) { Staticpress::Content::Index.new :number => 2 }
|
12
|
+
|
13
|
+
let(:chained) { Staticpress::Content::Page.new(:slug => 'chained') }
|
14
|
+
let(:chain) { Staticpress::Content::Page.new(:slug => 'chain.html') }
|
15
|
+
let(:page) { Staticpress::Content::Page.new(:slug => 'about') }
|
16
|
+
let(:second_page) { Staticpress::Content::Page.new :slug => 'contact' }
|
17
|
+
let(:page_root) { Staticpress::Content::Page.new :slug => '' }
|
18
|
+
let(:style_2) { Staticpress::Content::Page.new :slug => 'style2.css' }
|
19
|
+
let(:page_nested) { Staticpress::Content::Page.new :slug => 'foo/bar/baz' }
|
20
|
+
let(:static_bin) { Staticpress::Content::Page.new :slug => 'ruby.png' }
|
21
|
+
let(:static_txt) { Staticpress::Content::Page.new :slug => 'plain.txt' }
|
22
|
+
let(:page_fake) { Staticpress::Content::Page.new :slug => 'i/dont/exist' }
|
23
|
+
|
24
|
+
let(:post) { Staticpress::Content::Post.new(:year => '2011', :month => '07', :day => '20', :title => 'hello') }
|
25
|
+
let(:unpublished) { Staticpress::Content::Post.new(:year => '2012', :month => '09', :day => '19', :title => 'unpublished') }
|
26
|
+
|
27
|
+
let(:tag) { Staticpress::Content::Tag.new :name => 'charlotte' }
|
28
|
+
|
29
|
+
let(:asset_style) { Staticpress::Content::Theme.new :theme => 'test_theme', :asset_type => 'styles', :slug => 'all' }
|
30
|
+
let(:asset_script) { Staticpress::Content::Theme.new :theme => 'test_theme', :asset_type => 'scripts', :slug => 'application.js' }
|
31
|
+
|
32
|
+
describe '#==' do
|
33
|
+
it '...' do
|
34
|
+
expect(category).to be == Staticpress::Content::Category.new(:name => 'programming')
|
35
|
+
expect(category).to_not be == nil
|
36
|
+
|
37
|
+
expect(index).to be == Staticpress::Content::Index.new(:number => 1)
|
38
|
+
expect(index).to_not be == index_2
|
39
|
+
expect(index).to_not be == nil
|
40
|
+
|
41
|
+
expect(page).to be == Staticpress::Content::Page.new(:slug => 'about')
|
42
|
+
expect(page).to_not be == second_page
|
43
|
+
expect(page).to_not be == nil
|
44
|
+
expect(static_bin).to be == Staticpress::Content::Page.new(:slug => 'ruby.png')
|
45
|
+
expect(static_bin).to_not be == nil
|
46
|
+
expect(static_bin).to_not be == static_txt
|
47
|
+
|
48
|
+
expect(post).to be == Staticpress::Content::Post.new(:year => '2011', :month => '07', :day => '20', :title => 'hello')
|
49
|
+
expect(post).to_not be == nil
|
50
|
+
|
51
|
+
expect(tag).to be == Staticpress::Content::Tag.new(:name => 'charlotte')
|
52
|
+
expect(tag).to_not be == nil
|
53
|
+
|
54
|
+
expect(asset_style).to be == Staticpress::Content::Theme.new(:theme => 'test_theme', :asset_type => 'styles', :slug => 'all')
|
55
|
+
expect(asset_style).to_not be == nil
|
56
|
+
|
57
|
+
expect(Staticpress::Content::Category.new(:name => 'programming')).to_not be == Staticpress::Content::Tag.new(:name => 'programming')
|
58
|
+
expect(Staticpress::Content::Tag.new(:name => 'charlotte')).to_not be == Staticpress::Content::Category.new(:name => 'charlotte')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#content_type' do
|
63
|
+
it '...' do
|
64
|
+
expect(chained.content_type).to eq('text/html')
|
65
|
+
expect(page.content_type).to eq('text/html')
|
66
|
+
expect(style_2.content_type).to eq('text/css')
|
67
|
+
expect(static_bin.content_type).to eq('image/png')
|
68
|
+
expect(static_txt.content_type).to eq('text/plain')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#exist?' do
|
73
|
+
it '...' do
|
74
|
+
expect(category).to exist
|
75
|
+
expect(index).to exist
|
76
|
+
|
77
|
+
expect(chained).to exist
|
78
|
+
expect(chain).to exist
|
79
|
+
expect(page).to exist
|
80
|
+
expect(second_page).to exist
|
81
|
+
expect(static_bin).to exist
|
82
|
+
expect(static_txt).to exist
|
83
|
+
expect(page_root).to exist
|
84
|
+
|
85
|
+
expect(post).to exist
|
86
|
+
expect(unpublished).to exist
|
87
|
+
expect(tag).to exist
|
88
|
+
|
89
|
+
expect(asset_style).to exist
|
90
|
+
expect(asset_script).to exist
|
91
|
+
|
92
|
+
expect(page_fake).to_not exist
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '.find_by_url_path' do
|
97
|
+
it '...' do
|
98
|
+
expect(Staticpress::Content::Category.find_by_url_path('/category/programming')).to eq(category)
|
99
|
+
expect(Staticpress::Content::Index.find_by_url_path('/')).to eq(index)
|
100
|
+
|
101
|
+
expect(Staticpress::Content::Page.find_by_url_path('/')).to eq(page_root)
|
102
|
+
expect(Staticpress::Content::Page.find_by_url_path('/chained')).to eq(chained)
|
103
|
+
expect(Staticpress::Content::Page.find_by_url_path('/about')).to eq(page)
|
104
|
+
expect(Staticpress::Content::Page.find_by_url_path('/ruby.png')).to eq(static_bin)
|
105
|
+
|
106
|
+
expect(Staticpress::Content::Post.find_by_url_path('/2011/07/20/hello')).to eq(post)
|
107
|
+
expect(Staticpress::Content::Tag.find_by_url_path('/tag/charlotte')).to eq(tag)
|
108
|
+
|
109
|
+
expect(Staticpress::Content::Theme.find_by_url_path('/assets/test_theme/styles/all')).to eq(asset_style)
|
110
|
+
expect(Staticpress::Content::Theme.find_by_url_path('/assets/test_theme/scripts/application.js')).to eq(asset_script)
|
111
|
+
|
112
|
+
expect(Staticpress::Content::Theme.find_by_url_path(nil)).to be_nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#full_title' do
|
117
|
+
it '...' do
|
118
|
+
expect(page_nested.full_title).to eq('Foo -> Bar -> Baz | Test Blog')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '#markup_template?' do
|
123
|
+
it '...' do
|
124
|
+
expect(chained.markup_template?).to be_true
|
125
|
+
expect(chain.markup_template?).to be_true
|
126
|
+
expect(page.markup_template?).to be_true
|
127
|
+
|
128
|
+
expect(style_2.markup_template?).to be_false
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#output_path' do
|
133
|
+
it '...' do
|
134
|
+
output_directory = Staticpress.blog_path + 'public'
|
135
|
+
expect(chained.output_path).to eq(output_directory + 'chained' + 'index.html')
|
136
|
+
expect(chain.output_path).to eq(output_directory + 'chain.html')
|
137
|
+
expect(page.output_path).to eq(output_directory + 'about' + 'index.html')
|
138
|
+
expect(page_root.output_path).to eq(output_directory + 'index.html')
|
139
|
+
expect(style_2.output_path).to eq(output_directory + 'style2.css')
|
140
|
+
expect(static_bin.output_path).to eq(output_directory + 'ruby.png')
|
141
|
+
expect(static_txt.output_path).to eq(output_directory + 'plain.txt')
|
142
|
+
expect(post.output_path).to eq(output_directory + '2011' + '07' + '20' + 'hello' + 'index.html')
|
143
|
+
expect(asset_style.output_path).to eq(output_directory + 'assets' + 'test_theme' + 'styles' + 'all')
|
144
|
+
expect(asset_script.output_path).to eq(output_directory + 'assets' + 'test_theme' + 'scripts' + 'application.js')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#params' do
|
149
|
+
it '...' do
|
150
|
+
expected = { :name => 'charlotte', :number => 1 }
|
151
|
+
expect(tag.params).to eq(expected)
|
152
|
+
expect(Staticpress::Content::Tag.new(:name => 'charlotte', :number => nil).params).to eq(expected)
|
153
|
+
expect(Staticpress::Content::Tag.new(:name => 'charlotte', :number => 1).params).to eq(expected)
|
154
|
+
expect(Staticpress::Content::Tag.new(:name => 'charlotte', :number => '1').params).to eq(expected)
|
155
|
+
|
156
|
+
expect(Staticpress::Content::Page.new(:slug => 'chain.html').params).to eq(:slug => 'chain.html')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '#raw' do
|
161
|
+
it '...' do
|
162
|
+
expect(category.raw).to eq('= partial :list_posts, :posts => page.sub_content')
|
163
|
+
|
164
|
+
expect(chained.raw).to eq("<%= 'Processed with ERB' %>, then Markdown.")
|
165
|
+
expect(page.raw).to eq('in page')
|
166
|
+
expect(second_page.raw).to eq("in page\n\nin page")
|
167
|
+
expect(static_txt.raw).to eq('this file intentionally left blank')
|
168
|
+
|
169
|
+
expect(post.raw).to eq('in post')
|
170
|
+
expect(tag.raw).to eq('= partial :list_posts, :posts => page.sub_content')
|
171
|
+
expect(asset_style.raw).to eq('@import "compass/reset/utilities"')
|
172
|
+
|
173
|
+
expected = <<-JS
|
174
|
+
(function ($) {
|
175
|
+
$(document).ready(function () {
|
176
|
+
});
|
177
|
+
})(jQuery);
|
178
|
+
JS
|
179
|
+
expect(asset_script.raw).to eq(expected.strip)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#render' do
|
184
|
+
it '...' do
|
185
|
+
expected_page = <<-HTML
|
186
|
+
<!DOCTYPE html>
|
187
|
+
<html>
|
188
|
+
<head>
|
189
|
+
<title>About | Test Blog</title>
|
190
|
+
</head>
|
191
|
+
<body>
|
192
|
+
<p>in page</p>
|
193
|
+
</body>
|
194
|
+
</html>
|
195
|
+
HTML
|
196
|
+
expect(page.render).to eq(expected_page)
|
197
|
+
|
198
|
+
expected_style2 = <<-CSS
|
199
|
+
body{color:green}
|
200
|
+
CSS
|
201
|
+
expect(style_2.render).to eq(expected_style2)
|
202
|
+
|
203
|
+
expect(static_txt.render).to eq('this file intentionally left blank')
|
204
|
+
expect { asset_style.render }.to_not raise_error(Sass::SyntaxError)
|
205
|
+
|
206
|
+
expected = <<-SASS
|
207
|
+
SASS
|
208
|
+
expect(asset_style.render).to eq(expected)
|
209
|
+
|
210
|
+
expected = <<-JS
|
211
|
+
(function ($) {
|
212
|
+
$(document).ready(function () {
|
213
|
+
});
|
214
|
+
})(jQuery);
|
215
|
+
JS
|
216
|
+
expect(asset_script.render).to eq(expected)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe '#render_partial' do
|
221
|
+
it '...' do
|
222
|
+
expect(chained.render_partial).to eq("<p>Processed with ERB, then Markdown.</p>\n")
|
223
|
+
expect(page.render_partial).to eq("<p>in page</p>\n")
|
224
|
+
expect(second_page.render_partial).to eq("<p>in page</p>\n\n<p>in page</p>\n")
|
225
|
+
|
226
|
+
expected_style2 = <<-CSS
|
227
|
+
body{color:green}
|
228
|
+
CSS
|
229
|
+
expect(style_2.render_partial).to eq(expected_style2)
|
230
|
+
|
231
|
+
expect(static_txt.render_partial).to eq('this file intentionally left blank')
|
232
|
+
expect(post.render_partial).to eq("<p>in post</p>\n")
|
233
|
+
|
234
|
+
expect { asset_style.render_partial }.to_not raise_error(Sass::SyntaxError)
|
235
|
+
expected = <<-SASS
|
236
|
+
SASS
|
237
|
+
|
238
|
+
expect(asset_style.render_partial).to eq(expected)
|
239
|
+
expected = <<-JS
|
240
|
+
(function ($) {
|
241
|
+
$(document).ready(function () {
|
242
|
+
});
|
243
|
+
})(jQuery);
|
244
|
+
JS
|
245
|
+
expect(asset_script.render_partial).to eq(expected)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe '#save' do
|
250
|
+
it '...' do
|
251
|
+
static_bin.save
|
252
|
+
expect(static_bin.output_path.binread).to eq(static_bin.template_path.binread)
|
253
|
+
|
254
|
+
static_txt.save
|
255
|
+
expect(static_txt.output_path.read).to eq(static_txt.template_path.read)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe '#template_engine_options' do
|
260
|
+
it '...' do
|
261
|
+
expect(asset_script.template_engine_options(:sass)[:line_comments]).to be_false
|
262
|
+
expect(asset_script.template_engine_options(:sass)[:style]).to eq(:compressed)
|
263
|
+
expect(asset_script.template_engine_options(:js)).to eq({})
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe '#template_types' do
|
268
|
+
it '...' do
|
269
|
+
expect(chained.template_types).to eq([:erb, :markdown])
|
270
|
+
expect(chain.template_types).to eq([:erb, :markdown])
|
271
|
+
expect(page.template_types).to eq([:markdown])
|
272
|
+
expect(asset_style.template_types).to eq([:sass])
|
273
|
+
expect(asset_script.template_types).to eq([])
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe '#title' do
|
278
|
+
it '...' do
|
279
|
+
expect(page_nested.title).to eq('Foo -> Bar -> Baz')
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe '#to_s' do
|
284
|
+
it '...' do
|
285
|
+
expect(category.to_s).to eq('#<Staticpress::Content::Category url_path=/category/programming, params={:name=>"programming", :number=>1}>')
|
286
|
+
expect(Staticpress::Content::Category.new(:name => 'programming', :number => nil).to_s).to eq('#<Staticpress::Content::Category url_path=/category/programming, params={:name=>"programming", :number=>1}>')
|
287
|
+
|
288
|
+
expect(index.to_s).to eq('#<Staticpress::Content::Index url_path=/, params={:number=>1}>')
|
289
|
+
expect(index_2.to_s).to eq('#<Staticpress::Content::Index url_path=/page/2, params={:number=>2}>')
|
290
|
+
|
291
|
+
expect(page_root.to_s).to eq('#<Staticpress::Content::Page url_path=/, params={:slug=>""}>')
|
292
|
+
expect(page.to_s).to eq('#<Staticpress::Content::Page url_path=/about, params={:slug=>"about"}>')
|
293
|
+
expect(static_bin.to_s).to eq('#<Staticpress::Content::Page url_path=/ruby.png, params={:slug=>"ruby.png"}>')
|
294
|
+
|
295
|
+
expect(post.to_s).to eq('#<Staticpress::Content::Post url_path=/2011/07/20/hello, params={:day=>"20", :month=>"07", :title=>"hello", :year=>"2011"}>')
|
296
|
+
|
297
|
+
expect(tag.to_s).to eq('#<Staticpress::Content::Tag url_path=/tag/charlotte, params={:name=>"charlotte", :number=>1}>')
|
298
|
+
|
299
|
+
expect(asset_style.to_s).to eq('#<Staticpress::Content::Theme url_path=/assets/test_theme/styles/all, params={:asset_type=>"styles", :slug=>"all", :theme=>"test_theme"}>')
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe '#url_path' do
|
304
|
+
it '...' do
|
305
|
+
expect(category.url_path).to eq('/category/programming')
|
306
|
+
expect(category_1.url_path).to eq('/category/programming')
|
307
|
+
expect(category_2.url_path).to eq('/category/programming/page/2')
|
308
|
+
|
309
|
+
expect(index.url_path).to eq('/')
|
310
|
+
expect(index_2.url_path).to eq('/page/2')
|
311
|
+
|
312
|
+
expect(page_root.url_path).to eq('/')
|
313
|
+
expect(chained.url_path).to eq('/chained')
|
314
|
+
expect(chain.url_path).to eq('/chain.html')
|
315
|
+
expect(page.url_path).to eq('/about')
|
316
|
+
expect(second_page.url_path).to eq('/contact')
|
317
|
+
expect(static_bin.url_path).to eq('/ruby.png')
|
318
|
+
expect(static_txt.url_path).to eq('/plain.txt')
|
319
|
+
|
320
|
+
expect(post.url_path).to eq('/2011/07/20/hello')
|
321
|
+
|
322
|
+
expect(post.url_path).to eq('/2011/07/20/hello')
|
323
|
+
expect(tag.url_path).to eq('/tag/charlotte')
|
324
|
+
expect(asset_style.url_path).to eq('/assets/test_theme/styles/all')
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Staticpress::Content::Category do
|
4
|
+
include Staticpress::Helpers
|
5
|
+
|
6
|
+
basic_blog
|
7
|
+
|
8
|
+
let(:category) { Staticpress::Content::Category.new :name => 'programming' }
|
9
|
+
|
10
|
+
describe '.categories' do
|
11
|
+
it '...' do
|
12
|
+
expect(Staticpress::Content::Category.categories).to eq([ 'programming', 'travel' ])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#pages_count' do
|
17
|
+
it '...' do
|
18
|
+
expect(category.pages_count).to eq(1)
|
19
|
+
|
20
|
+
with_config :posts_per_page => 2 do
|
21
|
+
expect(category.pages_count).to eq(2)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#sub_content' do
|
27
|
+
it '...' do
|
28
|
+
expected = [
|
29
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '01', :title => 'announcing-staticpress'),
|
30
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '02', :title => 'staticpress'),
|
31
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress')
|
32
|
+
]
|
33
|
+
expect(category.sub_content).to eq(expected)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.all' do
|
38
|
+
it '...' do
|
39
|
+
with_config :posts_per_page => 1 do
|
40
|
+
expected = [
|
41
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 1),
|
42
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 2),
|
43
|
+
Staticpress::Content::Category.new(:name => 'programming', :number => 3),
|
44
|
+
Staticpress::Content::Category.new(:name => 'travel', :number => 1)
|
45
|
+
]
|
46
|
+
expect(Staticpress::Content::Category.all).to eq(expected)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '.content_by_category' do
|
52
|
+
it '...' do
|
53
|
+
[
|
54
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '01', :title => 'announcing-staticpress'),
|
55
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '02', :title => 'staticpress'),
|
56
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress')
|
57
|
+
].each { |content| expect(Staticpress::Content::Category.content_by_category['programming']).to include(content) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Staticpress::Content::Index do
|
4
|
+
include Staticpress::Helpers
|
5
|
+
|
6
|
+
basic_blog
|
7
|
+
|
8
|
+
let(:index) { Staticpress::Content::Index.new }
|
9
|
+
let(:unpublished) { Staticpress::Content::Post.new(:year => '2012', :month => '09', :day => '19', :title => 'unpublished') }
|
10
|
+
|
11
|
+
describe '#pages_count' do
|
12
|
+
it '...' do
|
13
|
+
expect(index.pages_count).to eq(1)
|
14
|
+
|
15
|
+
with_config :posts_per_page => 2 do
|
16
|
+
expect(index.pages_count).to eq(4)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#sub_content' do
|
22
|
+
it '...' do
|
23
|
+
with_config :posts_per_page => 4 do
|
24
|
+
# expect three most recent posts with oldest on top (index is lazy-evaluated)
|
25
|
+
expected = [
|
26
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'conferences'),
|
27
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress'),
|
28
|
+
Staticpress::Content::Post.new(:year => '2011', :month => '08', :day => '20', :title => 'forever')
|
29
|
+
]
|
30
|
+
expect(index.sub_content).to eq(expected)
|
31
|
+
expect(index.sub_content).to_not include(unpublished)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.all' do
|
37
|
+
it '...' do
|
38
|
+
with_config :posts_per_page => 3 do
|
39
|
+
expected = [
|
40
|
+
Staticpress::Content::Index.new(:number => 1),
|
41
|
+
Staticpress::Content::Index.new(:number => 2),
|
42
|
+
Staticpress::Content::Index.new(:number => 3)
|
43
|
+
]
|
44
|
+
expect(Staticpress::Content::Index.all).to eq(expected)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|