lanyon 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18793dd0415d539f17084ef5429627bc1035afac4ad154be2c813bff58865bd1
4
- data.tar.gz: 23516e59289257ae2d483124c2493c01fc91e44bb9ceefdbc1b510769535794a
3
+ metadata.gz: 2334bd94271d53dfd592043f857b993de778bbae9ae2d37599626d6eb438f49b
4
+ data.tar.gz: 32604e26502c3bcd42d2b671ef2147fe3136a024ef17b7b46dd5870886b8a867
5
5
  SHA512:
6
- metadata.gz: cedb0eaffd695e1ba9c7f492fdc0022e60d72d2c83deddb1a410803129fc9b180dceb075e365cd48b3b9d42e1bb74009753f49af1071115d0e9cdbba008c8bf2
7
- data.tar.gz: 2049a769b9ce0dae8e424abbf3ed908ce1b892c2023042047903c3c4df6d5636fc9c03b7107fd3105fe11f0fab230578ad95877e5cba0bdf72e6ac73858b891f
6
+ metadata.gz: 767061c55f75506891ec7a3e47f4ca9fa844cc9b28b68cfcb4ade8b17b23e2ef45c453a6a4c55d0289014423d35fa8640150160d3d758b4c28eed929e729c52b
7
+ data.tar.gz: 4e8f14f744ee127c8afb7e158ba8e4f737e6d856896d27b923bef728b396baa28f4aced6a58ff74b38511b8a1158570b9a19edc1e56a8486c35caac340d2eba4
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Release History
2
2
  ===============
3
3
 
4
+ ## 0.4.2
5
+
6
+ * Avoid deprecation warnings for minitest expectations
7
+ * Improve code style
8
+
4
9
  ## 0.4.1
5
10
 
6
11
  * Drop pessimistic constraint on Jekyll version
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2019 Marcus Stollsteimer
3
+ Copyright (c) 2015-2020 Marcus Stollsteimer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -56,7 +56,7 @@ or as Lanyon initialization options in `config.ru`.
56
56
  Example:
57
57
 
58
58
  ``` ruby
59
- run Lanyon.application(:destination => "mysite")
59
+ run Lanyon.application(destination: "mysite")
60
60
  ```
61
61
 
62
62
  This will set a custom destination path, overriding the default (`_site`)
@@ -70,7 +70,7 @@ Additional Lanyon initialization options:
70
70
  (default: false)
71
71
 
72
72
  Note that on read-only filesystems a site build will fail,
73
- so you must set `:skip_build => true` in these cases.
73
+ so you must set `skip_build: true` in these cases.
74
74
 
75
75
  ### Custum 404 Page
76
76
 
@@ -107,7 +107,7 @@ Lanyon was inspired by [rack-jekyll][rack-jekyll] and written as a replacement.
107
107
 
108
108
  ## License
109
109
 
110
- Copyright © 2015-2019 Marcus Stollsteimer
110
+ Copyright © 2015-2020 Marcus Stollsteimer
111
111
 
112
112
  Lanyon is licensed under the [MIT License][MIT].
113
113
  See also the included `LICENSE` file for more information.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ def gemspec_file
7
7
  end
8
8
 
9
9
 
10
- task :default => [:test]
10
+ task default: [:test]
11
11
 
12
12
  Rake::TestTask.new do |t|
13
13
  t.pattern = "test/**/test_*.rb"
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.summary = "Lanyon serves your Jekyll site as a Rack application."
12
12
  s.description =
13
- "Lanyon is a good friend of Jekyll, the static site generator, " +
13
+ "Lanyon is a good friend of Jekyll, the static site generator, " \
14
14
  "and transforms your website into a Rack application."
15
15
 
16
16
  s.authors = ["Marcus Stollsteimer"]
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "jekyll", ">= 2.0"
25
25
  s.add_dependency "rack", ">= 1.6", "< 3.0"
26
26
 
27
- s.add_development_dependency "rake", "~> 11.2"
28
27
  s.add_development_dependency "minitest", "~> 5.8"
28
+ s.add_development_dependency "rake", "~> 11.2"
29
29
 
30
30
  s.require_paths = ["lib"]
31
31
 
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  ] +
41
41
  Dir.glob("lib/**/*") +
42
42
  Dir.glob("test/**/*") +
43
- Dir.glob("demo/**/*").reject {|f| f =~ %r(\Ademo/_site/) }
43
+ Dir.glob("demo/**/*").reject {|f| f.start_with?("demo/_site/") }
44
44
 
45
45
  s.extra_rdoc_files = %w[README.md LICENSE History.md]
46
46
  s.rdoc_options = ["--charset=UTF-8", "--main=README.md"]
@@ -70,7 +70,7 @@ module Lanyon
70
70
 
71
71
  # @private
72
72
  def self.default_options # :nodoc:
73
- { :skip_build => false }
73
+ { skip_build: false }
74
74
  end
75
75
 
76
76
  # @private
@@ -44,7 +44,7 @@ module Lanyon
44
44
 
45
45
  def response(filename) # :nodoc:
46
46
  response = Rack::Response.new(File.binread(filename))
47
- response["Content-Type"] = media_type(filename)
47
+ response["Content-Type"] = media_type(filename)
48
48
 
49
49
  response.finish
50
50
  end
@@ -63,7 +63,7 @@ module Lanyon
63
63
  end
64
64
 
65
65
  def html_wrap(title, content) # :nodoc:
66
- <<-document.gsub(/^ {6}/, "")
66
+ <<-DOCUMENT.gsub(/^ {6}/, "")
67
67
  <!DOCTYPE html>
68
68
  <html lang="en">
69
69
  <head>
@@ -73,7 +73,7 @@ module Lanyon
73
73
  #{content}
74
74
  </body>
75
75
  </html>
76
- document
76
+ DOCUMENT
77
77
  end
78
78
 
79
79
  def default_404_body # :nodoc:
@@ -97,7 +97,7 @@ module Lanyon
97
97
  end
98
98
 
99
99
  def redirect_body(to_path) # :nodoc:
100
- message = %Q{<p>Redirecting to <a href="#{to_path}">#{to_path}</a>.</p>}
100
+ message = %Q(<p>Redirecting to <a href="#{to_path}">#{to_path}</a>.</p>)
101
101
 
102
102
  html_wrap("Redirection", message)
103
103
  end
@@ -110,9 +110,9 @@ module Lanyon
110
110
 
111
111
  body = redirect_body(location)
112
112
  headers = {
113
- "Location" => location,
113
+ "Location" => location,
114
114
  "Cache-Control" => "max-age=#{cache_time}, must-revalidate",
115
- "Expires" => (Time.now + cache_time).httpdate
115
+ "Expires" => (Time.now + cache_time).httpdate
116
116
  }
117
117
 
118
118
  html_response(body, 301, headers)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lanyon
4
- VERSION = "0.4.1"
5
- DATE = "2019-11-03"
4
+ VERSION = "0.4.2"
5
+ DATE = "2020-01-19"
6
6
  end
@@ -8,7 +8,7 @@ require "rack/mock"
8
8
  require "lanyon"
9
9
 
10
10
 
11
- TEST_DIR = File.expand_path("..", __FILE__)
11
+ TEST_DIR = File.expand_path(__dir__)
12
12
 
13
13
  SOURCE_DIR = File.join(TEST_DIR, "source")
14
14
  CACHE_DIR = File.join(SOURCE_DIR, ".jekyll-cache")
@@ -38,7 +38,6 @@ def sourcedir
38
38
  SOURCE_DIR
39
39
  end
40
40
 
41
-
42
41
  def silence_output
43
42
  original_stderr, original_stdout = $stderr, $stdout
44
43
  $stderr, $stdout = StringIO.new, StringIO.new
@@ -48,7 +47,6 @@ ensure
48
47
  $stderr, $stdout = original_stderr, original_stdout
49
48
  end
50
49
 
51
-
52
50
  def file_must_exist(filename)
53
51
  assert File.exist?(filename),
54
52
  "Expected file `#{filename}' to exist."
@@ -11,7 +11,7 @@ describe "when creating a Lanyon application" do
11
11
 
12
12
  destdir = File.join(tempdir, "_site")
13
13
 
14
- @dir_options = { :source => sourcedir, :destination => destdir }
14
+ @dir_options = { source: sourcedir, destination: destdir }
15
15
  @page = File.join(destdir, "index.html")
16
16
  @no_page = File.join(destdir, "not_a_page.html")
17
17
 
@@ -36,7 +36,7 @@ describe "when creating a Lanyon application" do
36
36
  end
37
37
 
38
38
  it "does not build the site when :skip_build option is set" do
39
- options = {:skip_build => true}.merge(@dir_options)
39
+ options = { skip_build: true }.merge(@dir_options)
40
40
  silence_output do
41
41
  Lanyon.application(options)
42
42
  end
@@ -46,7 +46,7 @@ describe "when creating a Lanyon application" do
46
46
  end
47
47
 
48
48
  it "does always build the site with ::build" do
49
- options = {:skip_build => true}.merge(@dir_options)
49
+ options = { skip_build: true }.merge(@dir_options)
50
50
  silence_output do
51
51
  Lanyon.build(options)
52
52
  end
@@ -25,7 +25,7 @@ describe "when configuring site" do
25
25
 
26
26
  it "loads the correct default destination" do
27
27
  config = get_jekyll_config
28
- config["destination"].must_equal File.join(Dir.pwd, "_site")
28
+ _(config["destination"]).must_equal File.join(Dir.pwd, "_site")
29
29
  end
30
30
  end
31
31
 
@@ -43,8 +43,8 @@ describe "when configuring site" do
43
43
 
44
44
  it "loads the configuration from file" do
45
45
  config = get_jekyll_config
46
- config.must_include "config_file_opt"
47
- config["config_file_opt"].must_equal "ok"
46
+ _(config).must_include "config_file_opt"
47
+ _(config["config_file_opt"]).must_equal "ok"
48
48
  end
49
49
  end
50
50
 
@@ -61,28 +61,28 @@ describe "when configuring site" do
61
61
  end
62
62
 
63
63
  it "loads the configuration from file" do
64
- config = get_jekyll_config(:config => "_my_config.yml")
65
- config.must_include "config_file_opt"
66
- config["config_file_opt"].must_equal "ok"
64
+ config = get_jekyll_config(config: "_my_config.yml")
65
+ _(config).must_include "config_file_opt"
66
+ _(config["config_file_opt"]).must_equal "ok"
67
67
  end
68
68
  end
69
69
 
70
70
  describe "when initialization options are given" do
71
71
 
72
72
  it "has the initialization options" do
73
- config = get_jekyll_config(:init_opt => "ok")
74
- config.must_include "init_opt"
75
- config["init_opt"].must_equal "ok"
73
+ config = get_jekyll_config(init_opt: "ok")
74
+ _(config).must_include "init_opt"
75
+ _(config["init_opt"]).must_equal "ok"
76
76
  end
77
77
 
78
78
  it "has the correct destination" do
79
- config = get_jekyll_config(:destination => "/project/_site")
80
- config["destination"].must_equal "/project/_site"
79
+ config = get_jekyll_config(destination: "/project/_site")
80
+ _(config["destination"]).must_equal "/project/_site"
81
81
  end
82
82
 
83
83
  it "does not pass :skip_build on to Jekyll" do
84
- config = get_jekyll_config(:skip_build => "ok")
85
- config.wont_include "skip_build"
84
+ config = get_jekyll_config(skip_build: "ok")
85
+ _(config).wont_include "skip_build"
86
86
  end
87
87
  end
88
88
 
@@ -101,17 +101,16 @@ describe "when configuring site" do
101
101
  end
102
102
 
103
103
  it "has all options and initialization options override file options" do
104
- config = get_jekyll_config(:init_opt => "ok",
105
- :common_opt => "from init")
106
- config.must_include "init_opt"
107
- config.must_include "config_file_opt"
108
- config.must_include "common_opt"
109
- config["common_opt"].must_equal "from init"
104
+ config = get_jekyll_config(init_opt: "ok", common_opt: "from init")
105
+ _(config).must_include "init_opt"
106
+ _(config).must_include "config_file_opt"
107
+ _(config).must_include "common_opt"
108
+ _(config["common_opt"]).must_equal "from init"
110
109
  end
111
110
 
112
111
  it "has the correct destination" do
113
- config = get_jekyll_config(:destination => "/project/_site_from_init")
114
- config["destination"].must_equal "/project/_site_from_init"
112
+ config = get_jekyll_config(destination: "/project/_site_from_init")
113
+ _(config["destination"]).must_equal "/project/_site_from_init"
115
114
  end
116
115
  end
117
116
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # encoding: UTF-8
3
2
 
4
3
  require_relative "helper"
5
4
 
@@ -19,7 +18,7 @@ describe "when handling requests" do
19
18
 
20
19
  @destdir = File.join(tempdir, "_site")
21
20
 
22
- app = get_app(:source => sourcedir, :destination => @destdir)
21
+ app = get_app(source: sourcedir, destination: @destdir)
23
22
  @request = Rack::MockRequest.new(app)
24
23
  end
25
24
 
@@ -36,23 +35,23 @@ describe "when handling requests" do
36
35
  end
37
36
 
38
37
  it "returns status 200" do
39
- @response.status.must_equal 200
38
+ _(@response.status).must_equal 200
40
39
  end
41
40
 
42
41
  it "returns correct Content-Length header" do
43
- @response.original_headers["Content-Length"].must_equal "17"
42
+ _(@response.original_headers["Content-Length"]).must_equal "17"
44
43
  end
45
44
 
46
45
  it "returns correct Content-Type header" do
47
- @response.headers["Content-Type"].must_equal "text/html"
46
+ _(@response.headers["Content-Type"]).must_equal "text/html"
48
47
  end
49
48
 
50
49
  it "returns an ETag header" do
51
- @response.headers["ETag"].wont_be_nil
50
+ _(@response.headers["ETag"]).wont_be_nil
52
51
  end
53
52
 
54
53
  it "returns correct body" do
55
- @response.body.must_match %r{<p>Home Page</p>}
54
+ _(@response.body).must_match %r{<p>Home Page</p>}
56
55
  end
57
56
  end
58
57
 
@@ -64,20 +63,20 @@ describe "when handling requests" do
64
63
  end
65
64
 
66
65
  it "returns status 200" do
67
- @response.status.must_equal 404
66
+ _(@response.status).must_equal 404
68
67
  end
69
68
 
70
69
  it "returns correct Content-Length header" do
71
- @response.original_headers["Content-Length"].must_equal "142"
70
+ _(@response.original_headers["Content-Length"]).must_equal "142"
72
71
  end
73
72
 
74
73
  it "returns correct Content-Type header" do
75
- @response.headers["Content-Type"].must_equal "text/html"
74
+ _(@response.headers["Content-Type"]).must_equal "text/html"
76
75
  end
77
76
 
78
77
  it "returns correct body" do
79
78
  expected = %r{<!DOCTYPE html>.*<p>404: Not Found</p>}m
80
- @response.body.must_match expected
79
+ _(@response.body).must_match expected
81
80
  end
82
81
  end
83
82
 
@@ -88,7 +87,7 @@ describe "when handling requests" do
88
87
  @custom_404 = File.join(sourcedir, "404.html")
89
88
  File.open(@custom_404, "w") {|f| f.print "Custom 404" }
90
89
 
91
- app = get_app(:source => sourcedir, :destination => @destdir)
90
+ app = get_app(source: sourcedir, destination: @destdir)
92
91
  request = Rack::MockRequest.new(app)
93
92
  @response = request.get("/not/a/page")
94
93
  end
@@ -98,15 +97,15 @@ describe "when handling requests" do
98
97
  end
99
98
 
100
99
  it "returns correct Content-Length header" do
101
- @response.original_headers["Content-Length"].must_equal "10"
100
+ _(@response.original_headers["Content-Length"]).must_equal "10"
102
101
  end
103
102
 
104
103
  it "returns correct Content-Type header" do
105
- @response.headers["Content-Type"].must_equal "text/html"
104
+ _(@response.headers["Content-Type"]).must_equal "text/html"
106
105
  end
107
106
 
108
107
  it "returns correct body" do
109
- @response.body.must_equal "Custom 404"
108
+ _(@response.body).must_equal "Custom 404"
110
109
  end
111
110
  end
112
111
 
@@ -118,19 +117,19 @@ describe "when handling requests" do
118
117
  end
119
118
 
120
119
  it "returns status 200" do
121
- @response.status.must_equal 200
120
+ _(@response.status).must_equal 200
122
121
  end
123
122
 
124
123
  it "returns correct Content-Type header" do
125
- @response.headers["Content-Type"].must_equal "text/html"
124
+ _(@response.headers["Content-Type"]).must_equal "text/html"
126
125
  end
127
126
 
128
127
  it "returns correct Content-Length header" do
129
- @response.original_headers["Content-Length"].must_equal "19"
128
+ _(@response.original_headers["Content-Length"]).must_equal "19"
130
129
  end
131
130
 
132
131
  it "returns correct body" do
133
- @response.body.must_match %r{<p>A Blog Post</p>}
132
+ _(@response.body).must_match %r{<p>A Blog Post</p>}
134
133
  end
135
134
  end
136
135
 
@@ -142,12 +141,12 @@ describe "when handling requests" do
142
141
  end
143
142
 
144
143
  it "returns status 200" do
145
- @response.status.must_equal 200
144
+ _(@response.status).must_equal 200
146
145
  end
147
146
 
148
147
  it "returns Content-Type 'application/octet-stream'" do
149
148
  type = @response.headers["Content-Type"]
150
- type.must_equal "application/octet-stream"
149
+ _(type).must_equal "application/octet-stream"
151
150
  end
152
151
  end
153
152
 
@@ -156,12 +155,12 @@ describe "when handling requests" do
156
155
 
157
156
  it "returns correct Content-Type for *.css" do
158
157
  type = @request.get("/css/test.css").headers["Content-Type"]
159
- type.must_equal "text/css"
158
+ _(type).must_equal "text/css"
160
159
  end
161
160
 
162
161
  it "returns correct Content-Type for *.min.js" do
163
162
  type = @request.get("/js/test.min.js").headers["Content-Type"]
164
- type.must_equal "application/javascript"
163
+ _(type).must_equal "application/javascript"
165
164
  end
166
165
  end
167
166
 
@@ -169,11 +168,11 @@ describe "when handling requests" do
169
168
  describe "when asked for partially matching paths" do
170
169
 
171
170
  it "returns status 404 for path 1" do
172
- @request.get("/2015/10/05/hello").status.must_equal 404
171
+ _(@request.get("/2015/10/05/hello").status).must_equal 404
173
172
  end
174
173
 
175
174
  it "returns status 404 for path 2" do
176
- @request.get("/10/05/hello-world.html").status.must_equal 404
175
+ _(@request.get("/10/05/hello-world.html").status).must_equal 404
177
176
  end
178
177
  end
179
178
 
@@ -184,8 +183,8 @@ describe "when handling requests" do
184
183
  filename = File.join(@destdir, "/../_site/index.html")
185
184
  assert File.exist?(filename)
186
185
 
187
- @response = @request.get("/../_site/index.html")
188
- @response.status.must_equal 404
186
+ response = @request.get("/../_site/index.html")
187
+ _(response.status).must_equal 404
189
188
  end
190
189
  end
191
190
 
@@ -193,23 +192,24 @@ describe "when handling requests" do
193
192
  describe "when a directory is requested" do
194
193
 
195
194
  it "redirects to 'directory/' for 'directory' with index.html" do
196
- @request.get("/dir-with-index").status.must_equal 301
195
+ _(@request.get("/dir-with-index").status).must_equal 301
197
196
  end
198
197
 
199
198
  it "returns status 200 for 'directory/' with index.html" do
200
- @request.get("/dir-with-index/").status.must_equal 200
199
+ _(@request.get("/dir-with-index/").status).must_equal 200
201
200
  end
202
201
 
203
202
  it "returns correct body for 'directory/' with index.html" do
204
- @request.get("/dir-with-index/").body.must_match %r{<p>Index of dir-with-index/</p>}
203
+ response_body = @request.get("/dir-with-index/").body
204
+ _(response_body).must_match %r{<p>Index of dir-with-index/</p>}
205
205
  end
206
206
 
207
207
  it "returns status 404 for 'directory' without index.html" do
208
- @request.get("/dir-without-index").status.must_equal 404
208
+ _(@request.get("/dir-without-index").status).must_equal 404
209
209
  end
210
210
 
211
211
  it "returns status 404 for 'directory/' without index.html" do
212
- @request.get("/dir-without-index/").status.must_equal 404
212
+ _(@request.get("/dir-without-index/").status).must_equal 404
213
213
  end
214
214
  end
215
215
 
@@ -221,20 +221,20 @@ describe "when handling requests" do
221
221
  end
222
222
 
223
223
  it "returns status 301" do
224
- @response.status.must_equal 301
224
+ _(@response.status).must_equal 301
225
225
  end
226
226
 
227
227
  it "returns correct Location header" do
228
- @response.headers["Location"].must_equal "/dir-with-index/"
228
+ _(@response.headers["Location"]).must_equal "/dir-with-index/"
229
229
  end
230
230
 
231
231
  it "returns a Cache-Control header" do
232
- @response.headers["Cache-Control"].wont_be_nil
232
+ _(@response.headers["Cache-Control"]).wont_be_nil
233
233
  end
234
234
 
235
235
  it "returns correct body" do
236
236
  expected = %r{<!DOCTYPE html>.*<a href="/dir-with-index/">}m
237
- @request.get("/dir-with-index").body.must_match expected
237
+ _(@request.get("/dir-with-index").body).must_match expected
238
238
  end
239
239
  end
240
240
 
@@ -247,11 +247,11 @@ describe "when handling requests" do
247
247
 
248
248
  it "returns correct body" do
249
249
  response_body = @response.body.force_encoding("UTF-8")
250
- response_body.must_match %r{<p>¡Buenos días!</p>}
250
+ _(response_body).must_match %r{<p>¡Buenos días!</p>}
251
251
  end
252
252
 
253
253
  it "returns the bytesize as Content-Length header" do
254
- @response.original_headers["Content-Length"].must_equal "23"
254
+ _(@response.original_headers["Content-Length"]).must_equal "23"
255
255
  end
256
256
  end
257
257
 
@@ -264,11 +264,11 @@ describe "when handling requests" do
264
264
 
265
265
  it "returns correct body" do
266
266
  expected = "File\r\nwith\r\nCRLF\r\nnewlines\r\n"
267
- @response.body.must_equal expected
267
+ _(@response.body).must_equal expected
268
268
  end
269
269
 
270
270
  it "returns the bytesize as Content-Length header" do
271
- @response.original_headers["Content-Length"].must_equal "28"
271
+ _(@response.original_headers["Content-Length"]).must_equal "28"
272
272
  end
273
273
  end
274
274
 
@@ -276,18 +276,18 @@ describe "when handling requests" do
276
276
  describe "when URL contains special characters" do
277
277
 
278
278
  it "returns status 200 for URL with escapes" do
279
- @response = @request.get("%2F2015%2F11%2F05%2Fhello-world.html")
280
- @response.status.must_equal 200
279
+ response = @request.get("%2F2015%2F11%2F05%2Fhello-world.html")
280
+ _(response.status).must_equal 200
281
281
  end
282
282
 
283
283
  it "returns status 200 for resource name with blank" do
284
- @response = @request.get("with%20blank.html")
285
- @response.status.must_equal 200
284
+ response = @request.get("with%20blank.html")
285
+ _(response.status).must_equal 200
286
286
  end
287
287
 
288
288
  it "returns status 200 for resource name with plus" do
289
- @response = @request.get("with+plus.html")
290
- @response.status.must_equal 200
289
+ response = @request.get("with+plus.html")
290
+ _(response.status).must_equal 200
291
291
  end
292
292
  end
293
293
 
@@ -305,20 +305,20 @@ describe "when handling requests" do
305
305
  end
306
306
 
307
307
  it "returns correct status code for unchanged '/'" do
308
- @request.get("/", @correct_etag).status.must_equal 304
308
+ _(@request.get("/", @correct_etag).status).must_equal 304
309
309
  end
310
310
 
311
311
  it "does not return a Content-Length header for unchanged '/'" do
312
312
  response = @request.get("/", @correct_etag)
313
- response.original_headers["Content-Length"].must_be_nil
313
+ _(response.original_headers["Content-Length"]).must_be_nil
314
314
  end
315
315
 
316
316
  it "returns correct status code for changed '/'" do
317
- @request.get("/", @other_etag).status.must_equal 200
317
+ _(@request.get("/", @other_etag).status).must_equal 200
318
318
  end
319
319
 
320
320
  it "returns correct status code for 404" do
321
- @request.get("/not/a/page", @other_etag).status.must_equal 404
321
+ _(@request.get("/not/a/page", @other_etag).status).must_equal 404
322
322
  end
323
323
  end
324
324
 
@@ -326,15 +326,15 @@ describe "when handling requests" do
326
326
  describe "when handling HEAD requests" do
327
327
 
328
328
  it "returns status 200 for '/'" do
329
- @request.head("/").status.must_equal 200
329
+ _(@request.head("/").status).must_equal 200
330
330
  end
331
331
 
332
332
  it "returns correct Content-Length header for '/'" do
333
- @request.head("/").original_headers["Content-Length"].must_equal "17"
333
+ _(@request.head("/").original_headers["Content-Length"]).must_equal "17"
334
334
  end
335
335
 
336
336
  it "does not return a body" do
337
- @request.head("/").body.must_equal ""
337
+ _(@request.head("/").body).must_equal ""
338
338
  end
339
339
  end
340
340
 
@@ -342,20 +342,21 @@ describe "when handling requests" do
342
342
  describe "when handling OPTIONS requests" do
343
343
 
344
344
  it "returns status 200" do
345
- @request.options("/").status.must_equal 200
345
+ _(@request.options("/").status).must_equal 200
346
346
  end
347
347
 
348
348
  it "returns correct Allow header" do
349
- @request.options("/").original_headers["Allow"].must_equal "GET,HEAD,OPTIONS"
349
+ response_allow_header = @request.options("/").original_headers["Allow"]
350
+ _(response_allow_header).must_equal "GET,HEAD,OPTIONS"
350
351
  end
351
352
 
352
353
  it "does not return a body" do
353
- @request.options("/").body.must_equal ""
354
+ _(@request.options("/").body).must_equal ""
354
355
  end
355
356
 
356
357
  it "returns 404 for nonexistent resource" do
357
- @request.options("/not/a/page").status.must_equal 404
358
- @request.options("/not/a/page").body.must_match %r{<p>404: Not Found</p>}
358
+ _(@request.options("/not/a/page").status).must_equal 404
359
+ _(@request.options("/not/a/page").body).must_match %r{<p>404: Not Found</p>}
359
360
  end
360
361
  end
361
362
 
@@ -363,15 +364,15 @@ describe "when handling requests" do
363
364
  describe "when handling POST, PUT, DELETE, and other requests" do
364
365
 
365
366
  it "returns status 405" do
366
- @request.post("/").status.must_equal 405
367
- @request.put("/").status.must_equal 405
368
- @request.delete("/").status.must_equal 405
369
- @request.request("OTHER", "/").status.must_equal 405
367
+ _(@request.post("/").status).must_equal 405
368
+ _(@request.put("/").status).must_equal 405
369
+ _(@request.delete("/").status).must_equal 405
370
+ _(@request.request("OTHER", "/").status).must_equal 405
370
371
  end
371
372
 
372
373
  it "returns correct body" do
373
374
  expected = %r{<!DOCTYPE html>.*<p>405: Method Not Allowed</p>}m
374
- @request.post("/").body.must_match expected
375
+ _(@request.post("/").body).must_match expected
375
376
  end
376
377
  end
377
378
  end
@@ -43,44 +43,44 @@ describe Lanyon::Router do
43
43
 
44
44
  it "returns path for '/'" do
45
45
  filename = File.join(@sitedir, "index.html")
46
- @router.endpoint("/").must_equal filename
46
+ _(@router.endpoint("/")).must_equal filename
47
47
  end
48
48
 
49
49
  it "returns existing path" do
50
50
  filename = File.join(@sitedir, "page.html")
51
- @router.endpoint("/page.html").must_equal filename
51
+ _(@router.endpoint("/page.html")).must_equal filename
52
52
  end
53
53
 
54
54
  it "returns existing path for resource without extension" do
55
55
  filename = File.join(@sitedir, "README")
56
- @router.endpoint("/README").must_equal filename
56
+ _(@router.endpoint("/README")).must_equal filename
57
57
  end
58
58
 
59
59
  it "returns :not_found for non-existent path" do
60
- @router.endpoint("/not-a-page.html").must_equal :not_found
60
+ _(@router.endpoint("/not-a-page.html")).must_equal :not_found
61
61
  end
62
62
 
63
63
  it "returns :not_found for partially matching paths" do
64
- @router.endpoint("/dir1/dir2/").must_equal :not_found
65
- @router.endpoint("/dir2/dir3").must_equal :not_found
66
- @router.endpoint("ir1/di").must_equal :not_found
64
+ _(@router.endpoint("/dir1/dir2/")).must_equal :not_found
65
+ _(@router.endpoint("/dir2/dir3")).must_equal :not_found
66
+ _(@router.endpoint("ir1/di")).must_equal :not_found
67
67
  end
68
68
 
69
69
  it "returns path for '/path/to/dir/' with index" do
70
70
  filename = File.join(@sitedir, "dir-with-index/index.html")
71
- @router.endpoint("/dir-with-index/").must_equal filename
71
+ _(@router.endpoint("/dir-with-index/")).must_equal filename
72
72
  end
73
73
 
74
74
  it "returns :must_redirect for '/path/to/dir' with index" do
75
- @router.endpoint("/dir-with-index").must_equal :must_redirect
75
+ _(@router.endpoint("/dir-with-index")).must_equal :must_redirect
76
76
  end
77
77
 
78
78
  it "returns :not_found for '/path/to/dir/' without index" do
79
- @router.endpoint("/dir-without-index/").must_equal :not_found
79
+ _(@router.endpoint("/dir-without-index/")).must_equal :not_found
80
80
  end
81
81
 
82
82
  it "returns :not_found for '/path/to/dir' without index" do
83
- @router.endpoint("/dir-without-index").must_equal :not_found
83
+ _(@router.endpoint("/dir-without-index")).must_equal :not_found
84
84
  end
85
85
  end
86
86
 
@@ -89,31 +89,31 @@ describe Lanyon::Router do
89
89
 
90
90
  it "returns existing path" do
91
91
  filename = File.join(@sitedir, "page.html")
92
- @router.endpoint("/page").must_equal filename
92
+ _(@router.endpoint("/page")).must_equal filename
93
93
  end
94
94
 
95
95
  describe "when both `foo' and `foo.html' exist" do
96
96
 
97
97
  it "returns `foo' and not `foo.html' when asked for `foo'" do
98
98
  filename = File.join(@sitedir, "foo")
99
- @router.endpoint("/foo").must_equal filename
99
+ _(@router.endpoint("/foo")).must_equal filename
100
100
  end
101
101
 
102
102
  it "can also serve `foo.html'" do
103
103
  filename = File.join(@sitedir, "foo.html")
104
- @router.endpoint("/foo.html").must_equal filename
104
+ _(@router.endpoint("/foo.html")).must_equal filename
105
105
  end
106
106
  end
107
107
 
108
108
  describe "when both `bar.html' and `bar/index.html' exist" do
109
109
 
110
110
  it "returns :must_redirect and not `bar.html' when asked for `bar'" do
111
- @router.endpoint("/bar").must_equal :must_redirect
111
+ _(@router.endpoint("/bar")).must_equal :must_redirect
112
112
  end
113
113
 
114
114
  it "can also serve `bar.html'" do
115
115
  filename = File.join(@sitedir, "bar.html")
116
- @router.endpoint("/bar.html").must_equal filename
116
+ _(@router.endpoint("/bar.html")).must_equal filename
117
117
  end
118
118
  end
119
119
  end
@@ -123,27 +123,27 @@ describe Lanyon::Router do
123
123
 
124
124
  it "discards leading '..' for existing path" do
125
125
  filename = File.join(@sitedir, "page.html")
126
- @router.endpoint("/../../page.html").must_equal filename
126
+ _(@router.endpoint("/../../page.html")).must_equal filename
127
127
  end
128
128
 
129
129
  it "allows safe directory traversal" do
130
130
  filename = File.join(@sitedir, "index.html")
131
- @router.endpoint("/dir1/../").must_equal filename
131
+ _(@router.endpoint("/dir1/../")).must_equal filename
132
132
  end
133
133
 
134
134
  it "returns :not_found for unsafe directory traversal 1" do
135
135
  filename = File.join(@sitedir, "/../_site/page.html")
136
136
  assert File.exist?(filename)
137
137
 
138
- @router.endpoint("/../_site/page.html").must_equal :not_found
138
+ _(@router.endpoint("/../_site/page.html")).must_equal :not_found
139
139
  end
140
140
 
141
141
  it "returns :not_found for unsafe directory traversal 2" do
142
- @router.endpoint("/%2E%2E/_site/").must_equal :not_found
142
+ _(@router.endpoint("/%2E%2E/_site/")).must_equal :not_found
143
143
  end
144
144
 
145
145
  it "returns :not_found for unsafe directory traversal 3" do
146
- @router.endpoint("/dir1/../dir1/../../_site/").must_equal :not_found
146
+ _(@router.endpoint("/dir1/../dir1/../../_site/")).must_equal :not_found
147
147
  end
148
148
  end
149
149
 
@@ -153,7 +153,7 @@ describe Lanyon::Router do
153
153
  describe "when 404.html does not exist" do
154
154
 
155
155
  it "returns nil" do
156
- @router.custom_404_body.must_be_nil
156
+ _(@router.custom_404_body).must_be_nil
157
157
  end
158
158
  end
159
159
 
@@ -169,7 +169,7 @@ describe Lanyon::Router do
169
169
  end
170
170
 
171
171
  it "returns correct body" do
172
- @router.custom_404_body.must_equal "Custom 404"
172
+ _(@router.custom_404_body).must_equal "Custom 404"
173
173
  end
174
174
  end
175
175
  end
@@ -179,14 +179,14 @@ describe Lanyon::Router do
179
179
 
180
180
  it "strips trailing slash from root" do
181
181
  router = Lanyon::Router.new(@sitedir + "/")
182
- router.root.must_equal @sitedir
182
+ _(router.root).must_equal @sitedir
183
183
  end
184
184
 
185
185
  it "does not append a trailing slash to root" do
186
186
  assert !@sitedir.end_with?("/")
187
187
 
188
188
  router = Lanyon::Router.new(@sitedir)
189
- router.root.must_equal @sitedir
189
+ _(router.root).must_equal @sitedir
190
190
  end
191
191
  end
192
192
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lanyon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Stollsteimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-03 00:00:00.000000000 Z
11
+ date: 2020-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -45,33 +45,33 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3.0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: rake
48
+ name: minitest
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '11.2'
53
+ version: '5.8'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '11.2'
60
+ version: '5.8'
61
61
  - !ruby/object:Gem::Dependency
62
- name: minitest
62
+ name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '5.8'
67
+ version: '11.2'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '5.8'
74
+ version: '11.2'
75
75
  description: Lanyon is a good friend of Jekyll, the static site generator, and transforms
76
76
  your website into a Rack application.
77
77
  email: sto.mar@web.de
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.3
143
+ rubygems_version: 3.1.2
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Lanyon serves your Jekyll site as a Rack application.