Skip to content

Commit 35f519f

Browse files
Merge pull request #319 from ashmaroli/verbose-test-files
Improve spec site fixture
2 parents 7e51d3f + f3ac46a commit 35f519f

15 files changed

+111
-57
lines changed

spec/fixtures/site/_config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
title: Your awesome title
22

3+
# Load the admin interface.
34
gems:
45
- jekyll-admin
56

7+
# Exclude these files from being processed.
68
exclude:
79
- Gemfile
810
- Gemfile.lock
@@ -17,6 +19,7 @@ defaults:
1719
values:
1820
some_front_matter: "default"
1921

22+
# Dummy Collection.
2023
collections:
2124
puppies:
2225
foo: bar

spec/fixtures/site/_data/data_file2.yml

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Welcome to Jekyll!
2+
#
3+
# This config file is meant for settings that affect your whole blog, values which you are expected to set up once and rarely edit after that. If you find
4+
# yourself editing this file very often, consider using Jekyll's data files feature for the data you need to update frequently.
5+
#
6+
# For technical reasons, this file is *NOT* reloaded automatically when you use
7+
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
8+
9+
# Site settings
10+
# These are used to personalize your new site. If you look in the HTML files, you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
11+
# You can create any custom variable you would like, and they will be accessible in the templates via {{ site.myvariable }}.
12+
title: Your awesome title
13+
14+
description: > # this means to ignore newlines until "baseurl:"
15+
Write an awesome description for your new site here. You can edit this
16+
line in _config.yml. It will appear in your document head meta (for
17+
Google search results) and in your feed.xml site description.
18+
baseurl: "" # the subpath of your site, e.g. /blog
19+
url: "" # the base hostname & protocol for your site, e.g. http://example.com
20+
twitter_username: jekyllrb
21+
github_username: jekyll
22+
23+
# Build settings
24+
markdown: kramdown
25+
theme: minima
26+
gems:
27+
- jekyll-feed
28+
- jekyll-admin
29+
30+
# Exclude from processing.
31+
# The following items will not be processed, by default. Create a custom list to override the default setting.
32+
exclude:
33+
- Gemfile
34+
- Gemfile.lock
35+
- node_modules
36+
- vendor/bundle/
37+
- vendor/cache/
38+
- vendor/gems/
39+
- vendor/ruby/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Post Within Subdirectory
3+
foo: bar
4+
---
5+
6+
# Test Post within `_posts/more posts`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: A Test Post Within Subdirectory
3+
foo: bar
4+
---
5+
6+
# Test Post within `_posts/more posts/some more posts`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Another Test Post Within Subdirectory
3+
foo: bar
4+
---
5+
6+
# Another Test Post within `_posts/more posts/some more posts`

spec/fixtures/site/_posts/test/2016-04-01-test.md

-5
This file was deleted.

spec/fixtures/site/_posts/test/other/2016-05-01-test.md

-5
This file was deleted.

spec/fixtures/site/_posts/test/other/2016-05-02-test.md

-5
This file was deleted.

spec/fixtures/site/icon-github.svg

+1
Loading

spec/jekyll-admin/server/collection_spec.rb

+46-37
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ def app
9191
get "/collections/posts/entries/"
9292
expect(last_response).to be_ok
9393
expect(entries.first["type"]).to eq("directory")
94-
expect(entries.first["name"]).to eq("test")
94+
expect(entries.first["name"]).to eq("more posts")
9595
end
9696

9797
it "lists documents in subdirectories" do
98-
get "/collections/posts/entries/test/other/"
98+
get "/collections/posts/entries/more%20posts/some%20more%20posts/"
9999
expect(last_response).to be_ok
100-
expect(first_document["id"]).to eq("/2016/05/02/test")
101-
expect(first_document["path"]).to eq("_posts/test/other/2016-05-02-test.md")
100+
expect(first_document["id"])
101+
.to eq("/2016/05/02/another-test-post-within-subdirectory")
102+
expect(first_document["path"])
103+
.to eq(
104+
"_posts/more posts/some more " \
105+
"posts/2016-05-02-another-test-post-within-subdirectory.md"
106+
)
102107
end
103108
end
104109
end
@@ -110,21 +115,21 @@ def app
110115

111116
context "getting a single document" do
112117
it "returns a collection document" do
113-
get "/collections/posts/2016-01-01-test.md"
118+
get "/collections/posts/2016-01-01-test-post.md"
114119
expect(last_response).to be_ok
115-
expect(last_response_parsed["title"]).to eq("Test")
120+
expect(last_response_parsed["title"]).to eq("Test Post")
116121
end
117122

118123
it "returns a collection document in subdirectories" do
119-
get "/collections/posts/test/2016-04-01-test.md"
124+
get "/collections/posts/more%20posts/2016-04-01-post-within-subdirectory.md"
120125
expect(last_response).to be_ok
121-
expect(last_response_parsed["title"]).to eq("Test")
126+
expect(last_response_parsed["title"]).to eq("Post Within Subdirectory")
122127
end
123128

124129
it "returns a collection document using the slashed ID" do
125-
get "/collections/posts/2016/01/01/test.md"
130+
get "/collections/posts/2016-01-01-test-post.md"
126131
expect(last_response).to be_ok
127-
expect(last_response_parsed["title"]).to eq("Test")
132+
expect(last_response_parsed["title"]).to eq("Test Post")
128133
end
129134

130135
it "returns a non-dated document" do
@@ -140,29 +145,29 @@ def app
140145
end
141146

142147
it "returns the rendered output" do
143-
get "/collections/posts/2016-01-01-test.md"
148+
get "/collections/posts/2016-01-01-test-post.md"
144149
expect(last_response).to be_ok
145150
expected = "<h1 id=\"test-post\">Test Post</h1>\n"
146151
expect(last_response_parsed["content"]).to eq(expected)
147152
end
148153

149154
it "returns the raw content" do
150-
get "/collections/posts/2016-01-01-test.md"
155+
get "/collections/posts/2016-01-01-test-post.md"
151156
expect(last_response).to be_ok
152157
expect(last_response_parsed["raw_content"]).to eq("# Test Post\n")
153158
end
154159

155160
%w(next previous).each do |direction|
156161
it "includes the #{direction} document non-recursively" do
157-
get "/collections/posts/2016-02-01-test.md"
162+
get "/collections/posts/2016-02-01-test-post-2.md"
158163
expect(last_response).to be_ok
159164
expect(last_response_parsed).to have_key(direction)
160165
expect(last_response_parsed[direction]).to_not have_key("next")
161166
expect(last_response_parsed[direction]).to_not have_key("previous")
162167
end
163168

164169
it "doesn't include the #{direction} document's content" do
165-
get "/collections/posts/2016-02-01-test.md"
170+
get "/collections/posts/2016-02-01-test-post-2.md"
166171
expect(last_response).to be_ok
167172
expect(last_response_parsed).to have_key(direction)
168173
expect(last_response_parsed[direction]).to_not have_key("content")
@@ -175,18 +180,18 @@ def app
175180
let(:front_matter) { last_response_parsed["front_matter"] }
176181

177182
it "contains front matter defaults" do
178-
get "/collections/posts/2016-01-01-test.md"
183+
get "/collections/posts/2016-01-01-test-post.md"
179184
expect(last_response_parsed.key?("some_front_matter")).to eql(true)
180185
end
181186

182187
it "contains raw front matter" do
183-
get "/collections/posts/2016-01-01-test.md"
188+
get "/collections/posts/2016-01-01-test-post.md"
184189
expect(last_response_parsed.key?("front_matter")).to eql(true)
185190
expect(front_matter["foo"]).to eql("bar")
186191
end
187192

188193
it "raw front matter doesn't contain defaults" do
189-
get "/collections/posts/2016-01-01-test.md"
194+
get "/collections/posts/2016-01-01-test-post.md"
190195
expect(front_matter.key?("some_front_matter")).to eql(false)
191196
end
192197
end
@@ -234,19 +239,19 @@ def app
234239
end
235240

236241
it "writes a new file in subdirectories" do
237-
delete_file "_posts/test/2016-01-01-test2.md"
242+
delete_file "_posts/more posts/2016-01-01-test2.md"
238243

239244
request = {
240245
:front_matter => { :foo => "bar" },
241246
:raw_content => "test",
242247
}
243-
put "/collections/posts/test/2016-01-01-test2.md", request.to_json
248+
put "/collections/posts/more%20posts/2016-01-01-test2.md", request.to_json
244249

245250
expect(last_response).to be_ok
246251
expect(last_response_parsed["foo"]).to eq("bar")
247-
expect("_posts/test/2016-01-01-test2.md").to be_an_existing_file
252+
expect("_posts/more posts/2016-01-01-test2.md").to be_an_existing_file
248253

249-
delete_file "_posts/test/2016-01-01-test2.md"
254+
delete_file "_posts/more posts/2016-01-01-test2.md"
250255
end
251256

252257
it "updates a file" do
@@ -266,19 +271,19 @@ def app
266271
end
267272

268273
it "updates a file in subdirectories" do
269-
write_file "_posts/test/2016-01-01-test2.md"
274+
write_file "_posts/more posts/2016-01-01-test2.md"
270275

271276
request = {
272277
:front_matter => { :foo => "bar2" },
273278
:raw_content => "test",
274279
}
275-
put "/collections/posts/test/2016-01-01-test2.md", request.to_json
280+
put "/collections/posts/more%20posts/2016-01-01-test2.md", request.to_json
276281

277282
expect(last_response).to be_ok
278283
expect(last_response_parsed["foo"]).to eq("bar2")
279-
expect("_posts/test/2016-01-01-test2.md").to be_an_existing_file
284+
expect("_posts/more posts/2016-01-01-test2.md").to be_an_existing_file
280285

281-
delete_file "_posts/test/2016-01-01-test2.md"
286+
delete_file "_posts/more posts/2016-01-01-test2.md"
282287
end
283288

284289
it "writes a new file with a future date" do
@@ -326,28 +331,31 @@ def app
326331
end
327332

328333
it "renames a file in subdirectories" do
329-
write_file "_posts/test/2016-01-01-test2.md"
330-
delete_file "_posts/test/2016-01-02-test2.md"
334+
write_file "_posts/more posts/2016-01-01-test2.md"
335+
delete_file "_posts/more posts/2016-01-02-test2.md"
331336

332-
path = "_posts/test/2016-01-02-test2.md"
337+
path = "_posts/more posts/2016-01-02-test2.md"
333338
request = {
334339
:path => path,
335340
:front_matter => { :foo => "bar2" },
336341
:raw_content => "test",
337342
}
338343

339-
put "/collections/posts/test/2016-01-01-test2.md", request.to_json
344+
put "/collections/posts/more%20posts/2016-01-01-test2.md", request.to_json
340345
expect(last_response).to be_ok
341346
expect(last_response_parsed["foo"]).to eq("bar2")
342347

343-
get "/collections/posts/test/2016-01-02-test2.md", request.to_json
348+
get "/collections/posts/more%20posts/2016-01-02-test2.md", request.to_json
344349
expect(last_response).to be_ok
345350
expect(last_response_parsed["foo"]).to eq("bar2")
346351

347-
expect("_posts/test/2016-01-01-test2.md").to_not be_an_existing_file
348-
expect("_posts/test/2016-01-02-test2.md").to be_an_existing_file
352+
expect("_posts/more posts/2016-01-01-test2.md").to_not be_an_existing_file
353+
expect("_posts/more posts/2016-01-02-test2.md").to be_an_existing_file
349354

350-
delete_file "_posts/test/2016-01-01-test2.md", "_posts/test/2016-01-02-test2.md"
355+
delete_file(
356+
"_posts/more posts/2016-01-01-test2.md",
357+
"_posts/more posts/2016-01-02-test2.md"
358+
)
351359
end
352360
end
353361

@@ -359,10 +367,11 @@ def app
359367
end
360368

361369
it "deletes a file in subdirectories" do
362-
write_file "_posts/test/other/2017-01-01-test.md"
363-
delete "/collections/posts/test/other/2017-01-01-test.md"
370+
write_file "_posts/more posts/some more posts/2017-01-01-test.md"
371+
delete "/collections/posts/more%20posts/some%20more%20posts/2017-01-01-test.md"
364372
expect(last_response).to be_ok
365-
expect("_posts/test/other/2017-01-01-test.md").to_not be_an_existing_file
366-
delete_file "_posts/test/other/2017-01-01-test.md"
373+
expect("_posts/more posts/some more posts/2017-01-01-test.md")
374+
.to_not be_an_existing_file
375+
delete_file "_posts/more posts/some more posts/2017-01-01-test.md"
367376
end
368377
end

spec/jekyll-admin/urlable_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
context "posts" do
3636
subject { JekyllAdmin.site.posts.docs.first }
37-
let(:http_url) { "#{url_base}/2016/01/01/test.html" }
38-
let(:api_url) { "#{url_base}/#{prefix}/collections/posts/2016-01-01-test.md" }
37+
let(:http_url) { "#{url_base}/2016/01/01/test-post.html" }
38+
let(:api_url) { "#{url_base}/#{prefix}/collections/posts/2016-01-01-test-post.md" }
3939

4040
it "knows the HTTP URL" do
4141
expect(subject.http_url).to eql(http_url)
@@ -90,8 +90,8 @@
9090

9191
context "static files" do
9292
subject { JekyllAdmin.site.static_files.first }
93-
let(:http_url) { "#{url_base}/index.html" }
94-
let(:api_url) { "#{url_base}/#{prefix}/static_files/index.html" }
93+
let(:http_url) { "#{url_base}/icon-github.svg" }
94+
let(:api_url) { "#{url_base}/#{prefix}/static_files/icon-github.svg" }
9595

9696
it "knows the HTTP URL" do
9797
expect(subject.http_url).to eql(http_url)

0 commit comments

Comments
 (0)