History

Specs all passing

Paul Sernatinger committed 3 years ago

Commit 2da05d71 parent b3e55ed37 files · +198 −178Browse files

Unified · Split

37 files
  1. .ruby-version +1 −1
  2. Gemfile +24 −23
  3. Gemfile.lock +74 −71
  4. docs/maintainers.md +1 −0
  5. lib/app.rb +16 −1
  6. lib/docs/core/request.rb +1 −1
  7. lib/docs/core/requester.rb +8 −8
  8. lib/docs/core/scraper.rb +1 −1
  9. lib/tasks/updates.thor +1 −1
  10. test/lib/docs/core/doc_test.rb +5 −5
  11. test/lib/docs/core/entry_index_test.rb +2 −2
  12. test/lib/docs/core/filter_test.rb +3 −3
  13. test/lib/docs/core/instrumentable_test.rb +2 −2
  14. test/lib/docs/core/manifest_test.rb +2 −2
  15. test/lib/docs/core/models/entry_test.rb +2 −2
  16. test/lib/docs/core/models/type_test.rb +2 −2
  17. test/lib/docs/core/parser_test.rb +2 −2
  18. test/lib/docs/core/request_test.rb +4 −4
  19. test/lib/docs/core/requester_test.rb +4 −4
  20. test/lib/docs/core/response_test.rb +2 −2
  21. test/lib/docs/core/scraper_test.rb +3 −3
  22. test/lib/docs/core/scrapers/file_scraper_test.rb +2 −2
  23. test/lib/docs/core/scrapers/url_scraper_test.rb +7 −7
  24. test/lib/docs/core/url_test.rb +2 −2
  25. test/lib/docs/filters/core/apply_base_url_test.rb +2 −2
  26. test/lib/docs/filters/core/clean_html_test.rb +2 −2
  27. test/lib/docs/filters/core/clean_text_test.rb +2 −2
  28. test/lib/docs/filters/core/container_test.rb +2 −2
  29. test/lib/docs/filters/core/entries_test.rb +2 −2
  30. test/lib/docs/filters/core/inner_html_test.rb +2 −2
  31. test/lib/docs/filters/core/internal_urls_test.rb +2 −2
  32. test/lib/docs/filters/core/normalize_paths_test.rb +2 −2
  33. test/lib/docs/filters/core/normalize_urls_test.rb +2 −2
  34. test/lib/docs/filters/core/parse_cf_email_test.rb +2 −2
  35. test/lib/docs/filters/core/title_test.rb +2 −2
  36. test/lib/docs/storage/abstract_store_test.rb +3 −3
  37. test/lib/docs/storage/file_store_test.rb +2 −2
.ruby-version+1−1
@@ -1 +1 @@
12.7.613.1.2
Gemfile+24−23
@@ -1,37 +1,38 @@
1source 'https://rubygems.org'1source 'https://rubygems.org'
2ruby '~> 2.7.3'2ruby '3.1.2'
3 3
4gem 'rake'4gem 'activesupport', require: false
5gem 'thor'
6gem 'pry', '~> 0.14.0'
7gem 'activesupport', '~> 5.2', require: false
8gem 'yajl-ruby', require: false
9gem 'html-pipeline'5gem 'html-pipeline'
10gem 'typhoeus'
11gem 'nokogiri'6gem 'nokogiri'
7gem 'pry-byebug'
8gem 'rake'
12gem 'terminal-table'9gem 'terminal-table'
10gem 'thor'
11gem 'typhoeus'
12gem 'yajl-ruby', require: false
13 13
14group :app do14group :app do
15 gem 'browser'
16 gem 'chunky_png'
17 gem 'coffee-script'
18 gem 'erubi'
19 gem 'image_optim_pack', platforms: :ruby
20 gem 'image_optim'
21 gem 'rack-ssl-enforcer'
15 gem 'rack'22 gem 'rack'
16 gem 'sinatra'23 gem 'rss'
24 gem 'sass'
17 gem 'sinatra-contrib'25 gem 'sinatra-contrib'
18 gem 'rack-ssl-enforcer'26 gem 'sinatra'
19 gem 'thin'
20 gem 'sprockets'
21 gem 'sprockets-helpers'27 gem 'sprockets-helpers'
22 gem 'erubi'
23 gem 'browser'
24 gem 'sass'
25 gem 'coffee-script'
26 gem 'chunky_png'
27 gem 'sprockets-sass'28 gem 'sprockets-sass'
28 gem 'image_optim'29 gem 'sprockets'
29 gem 'image_optim_pack', platforms: :ruby30 gem 'thin'
30end31end
31 32
32group :production do33group :production do
33 gem 'uglifier'
34 gem 'newrelic_rpm'34 gem 'newrelic_rpm'
35 gem 'uglifier'
35end36end
36 37
37group :development do38group :development do
@@ -39,17 +40,17 @@ group :development do · 1 unmodified line
39end40end
40 41
41group :docs do42group :docs do
42 gem 'redcarpet'43 gem 'net-sftp', require: false
43 gem 'progress_bar', require: false44 gem 'progress_bar', require: false
44 gem 'unix_utils', require: false45 gem 'redcarpet'
45 gem 'tty-pager', require: false46 gem 'tty-pager', require: false
46 gem 'net-sftp', '>= 2.1.3.rc2', require: false47 gem 'unix_utils', require: false
47end48end
48 49
49group :test do50group :test do
50 gem 'minitest'51 gem 'minitest'
51 gem 'rr', require: false
52 gem 'rack-test', require: false52 gem 'rack-test', require: false
53 gem 'rr', require: false
53end54end
54 55
55if ENV['SELENIUM'] == '1'56if ENV['SELENIUM'] == '1'
Gemfile.lock+74−71
@@ -1,136 +1,138 @@
1GEM1GEM
2 remote: https://rubygems.org/2 remote: https://rubygems.org/
3 specs:3 specs:
4 activesupport (5.2.6)4 activesupport (7.0.4)
5 concurrent-ruby (~> 1.0, >= 1.0.2)5 concurrent-ruby (~> 1.0, >= 1.0.2)
6 i18n (>= 0.7, < 2)6 i18n (>= 1.6, < 2)
7 minitest (~> 5.1)7 minitest (>= 5.1)
8 tzinfo (~> 1.1)8 tzinfo (~> 2.0)
9 backports (3.15.0)
10 better_errors (2.9.1)9 better_errors (2.9.1)
11 coderay (>= 1.0.0)10 coderay (>= 1.0.0)
12 erubi (>= 1.0.0)11 erubi (>= 1.0.0)
13 rack (>= 0.9.0)12 rack (>= 0.9.0)
14 browser (2.6.1)13 browser (5.3.1)
15 chunky_png (1.3.11)14 byebug (11.1.3)
15 chunky_png (1.4.0)
16 coderay (1.1.3)16 coderay (1.1.3)
17 coffee-script (2.4.1)17 coffee-script (2.4.1)
18 coffee-script-source18 coffee-script-source
19 execjs19 execjs
20 coffee-script-source (1.12.2)20 coffee-script-source (1.12.2)
21 concurrent-ruby (1.1.9)21 concurrent-ruby (1.1.10)
22 daemons (1.4.0)22 daemons (1.4.1)
23 erubi (1.10.0)23 erubi (1.11.0)
24 ethon (0.12.0)24 ethon (0.16.0)
25 ffi (>= 1.3.0)25 ffi (>= 1.15.0)
26 eventmachine (1.2.7)26 eventmachine (1.2.7)
27 execjs (2.7.0)27 execjs (2.8.1)
28 exifr (1.3.6)28 exifr (1.3.10)
29 ffi (1.15.5)29 ffi (1.15.5)
30 fspath (3.1.2)30 fspath (3.1.2)
31 highline (2.0.3)31 highline (2.0.3)
32 html-pipeline (2.12.0)32 html-pipeline (2.14.3)
33 activesupport (>= 2)33 activesupport (>= 2)
34 nokogiri (>= 1.4)34 nokogiri (>= 1.4)
35 i18n (1.8.10)35 i18n (1.12.0)
36 concurrent-ruby (~> 1.0)36 concurrent-ruby (~> 1.0)
37 image_optim (0.26.5)37 image_optim (0.31.1)
38 exifr (~> 1.2, >= 1.2.2)38 exifr (~> 1.2, >= 1.2.2)
39 fspath (~> 3.0)39 fspath (~> 3.0)
40 image_size (>= 1.5, < 3)40 image_size (>= 1.5, < 4)
41 in_threads (~> 1.3)41 in_threads (~> 1.3)
42 progress (~> 3.0, >= 3.0.1)42 progress (~> 3.0, >= 3.0.1)
43 image_optim_pack (0.6.0)43 image_optim_pack (0.9.1.20221104)
44 fspath (>= 2.1, < 4)44 fspath (>= 2.1, < 4)
45 image_optim (~> 0.19)45 image_optim (~> 0.19)
46 image_size (2.0.2)46 image_size (3.2.0)
47 in_threads (1.5.3)47 in_threads (1.6.0)
48 method_source (1.0.0)48 method_source (1.0.0)
49 mini_portile2 (2.8.0)49 mini_portile2 (2.8.0)
50 minitest (5.14.4)50 minitest (5.16.3)
51 multi_json (1.13.1)51 multi_json (1.15.0)
52 mustermann (1.1.1)52 mustermann (3.0.0)
53 ruby2_keywords (~> 0.0.1)53 ruby2_keywords (~> 0.0.1)
54 net-sftp (3.0.0.beta1)54 net-sftp (4.0.0)
55 net-ssh (>= 5.0.0, < 6.0.0)55 net-ssh (>= 5.0.0, < 8.0.0)
56 net-ssh (5.2.0)56 net-ssh (7.0.1)
57 newrelic_rpm (6.7.0.359)57 newrelic_rpm (8.12.0)
58 nokogiri (1.13.9)58 nokogiri (1.13.9)
59 mini_portile2 (~> 2.8.0)59 mini_portile2 (~> 2.8.0)
60 racc (~> 1.4)60 racc (~> 1.4)
61 options (2.3.2)61 options (2.3.2)
62 progress (3.5.2)62 progress (3.6.0)
63 progress_bar (1.3.0)63 progress_bar (1.3.3)
64 highline (>= 1.6, < 3)64 highline (>= 1.6, < 3)
65 options (~> 2.3.0)65 options (~> 2.3.0)
66 pry (0.14.1)66 pry (0.14.1)
67 coderay (~> 1.1)67 coderay (~> 1.1)
68 method_source (~> 1.0)68 method_source (~> 1.0)
69 pry-byebug (3.10.1)
70 byebug (~> 11.0)
71 pry (>= 0.13, < 0.15)
69 racc (1.6.0)72 racc (1.6.0)
70 rack (2.2.3.1)73 rack (2.2.4)
71 rack-protection (2.0.7)74 rack-protection (3.0.3)
72 rack75 rack
73 rack-ssl-enforcer (0.2.9)76 rack-ssl-enforcer (0.2.9)
74 rack-test (1.1.0)77 rack-test (2.0.2)
75 rack (>= 1.0, < 3)78 rack (>= 1.3)
76 rake (13.0.0)79 rake (13.0.6)
77 rb-fsevent (0.10.3)80 rb-fsevent (0.11.2)
78 rb-inotify (0.10.0)81 rb-inotify (0.10.1)
79 ffi (~> 1.0)82 ffi (~> 1.0)
80 redcarpet (3.5.1)83 redcarpet (3.5.1)
81 rr (1.2.1)84 rexml (3.2.5)
85 rr (3.1.0)
86 rss (0.2.9)
87 rexml
82 ruby2_keywords (0.0.5)88 ruby2_keywords (0.0.5)
83 sass (3.7.4)89 sass (3.7.4)
84 sass-listen (~> 4.0.0)90 sass-listen (~> 4.0.0)
85 sass-listen (4.0.0)91 sass-listen (4.0.0)
86 rb-fsevent (~> 0.9, >= 0.9.4)92 rb-fsevent (~> 0.9, >= 0.9.4)
87 rb-inotify (~> 0.9, >= 0.9.7)93 rb-inotify (~> 0.9, >= 0.9.7)
88 sinatra (2.0.7)94 sinatra (3.0.3)
89 mustermann (~> 1.0)95 mustermann (~> 3.0)
90 rack (~> 2.0)96 rack (~> 2.2, >= 2.2.4)
91 rack-protection (= 2.0.7)97 rack-protection (= 3.0.3)
92 tilt (~> 2.0)98 tilt (~> 2.0)
93 sinatra-contrib (2.0.7)99 sinatra-contrib (3.0.3)
94 backports (>= 2.8.2)
95 multi_json100 multi_json
96 mustermann (~> 1.0)101 mustermann (~> 3.0)
97 rack-protection (= 2.0.7)102 rack-protection (= 3.0.3)
98 sinatra (= 2.0.7)103 sinatra (= 3.0.3)
99 tilt (~> 2.0)104 tilt (~> 2.0)
100 sprockets (3.7.2)105 sprockets (3.7.2)
101 concurrent-ruby (~> 1.0)106 concurrent-ruby (~> 1.0)
102 rack (> 1, < 3)107 rack (> 1, < 3)
103 sprockets-helpers (1.2.1)108 sprockets-helpers (1.4.0)
104 sprockets (>= 2.2)109 sprockets (>= 2.2)
105 sprockets-sass (2.0.0.beta2)110 sprockets-sass (2.0.0.beta2)
106 sprockets (>= 2.0, < 4.0)111 sprockets (>= 2.0, < 4.0)
107 strings (0.1.6)112 strings (0.2.1)
108 strings-ansi (~> 0.1)113 strings-ansi (~> 0.2)
109 unicode-display_width (~> 1.5)114 unicode-display_width (>= 1.5, < 3.0)
110 unicode_utils (~> 1.4)115 unicode_utils (~> 1.4)
111 strings-ansi (0.1.0)116 strings-ansi (0.2.0)
112 terminal-table (1.8.0)117 terminal-table (3.0.2)
113 unicode-display_width (~> 1.1, >= 1.1.1)118 unicode-display_width (>= 1.1.1, < 3)
114 thin (1.8.1)119 thin (1.8.1)
115 daemons (~> 1.0, >= 1.0.9)120 daemons (~> 1.0, >= 1.0.9)
116 eventmachine (~> 1.0, >= 1.0.4)121 eventmachine (~> 1.0, >= 1.0.4)
117 rack (>= 1, < 3)122 rack (>= 1, < 3)
118 thor (0.20.3)123 thor (1.2.1)
119 thread_safe (0.3.6)124 tilt (2.0.11)
120 tilt (2.0.10)125 tty-pager (0.14.0)
121 tty-pager (0.12.1)126 strings (~> 0.2.0)
122 strings (~> 0.1.4)127 tty-screen (~> 0.8)
123 tty-screen (~> 0.6)128 tty-screen (0.8.1)
124 tty-which (~> 0.4)129 typhoeus (1.4.0)
125 tty-screen (0.7.0)
126 tty-which (0.4.1)
127 typhoeus (1.3.1)
128 ethon (>= 0.9.0)130 ethon (>= 0.9.0)
129 tzinfo (1.2.10)131 tzinfo (2.0.5)
130 thread_safe (~> 0.1)132 concurrent-ruby (~> 1.0)
131 uglifier (4.2.0)133 uglifier (4.2.0)
132 execjs (>= 0.3.0, < 3)134 execjs (>= 0.3.0, < 3)
133 unicode-display_width (1.6.0)135 unicode-display_width (2.3.0)
134 unicode_utils (1.4.0)136 unicode_utils (1.4.0)
135 unix_utils (0.0.15)137 unix_utils (0.0.15)
136 yajl-ruby (1.4.3)138 yajl-ruby (1.4.3)
@@ -139,7 +141,7 @@ PLATFORMS · 2 unmodified lines
139 ruby141 ruby
140 142
141DEPENDENCIES143DEPENDENCIES
142 activesupport (~> 5.2)144 activesupport
143 better_errors145 better_errors
144 browser146 browser
145 chunky_png147 chunky_png
@@ -149,17 +151,18 @@ DEPENDENCIES · 3 unmodified lines
149 image_optim151 image_optim
150 image_optim_pack152 image_optim_pack
151 minitest153 minitest
152 net-sftp (>= 2.1.3.rc2)154 net-sftp
153 newrelic_rpm155 newrelic_rpm
154 nokogiri156 nokogiri
155 progress_bar157 progress_bar
156 pry (~> 0.14.0)158 pry-byebug
157 rack159 rack
158 rack-ssl-enforcer160 rack-ssl-enforcer
159 rack-test161 rack-test
160 rake162 rake
161 redcarpet163 redcarpet
162 rr164 rr
165 rss
163 sass166 sass
164 sinatra167 sinatra
165 sinatra-contrib168 sinatra-contrib
@@ -176,7 +179,7 @@ DEPENDENCIES · 10 unmodified lines
176 yajl-ruby179 yajl-ruby
177 180
178RUBY VERSION181RUBY VERSION
179 ruby 2.7.3p183182 ruby 3.1.2p20
180 183
181BUNDLED WITH184BUNDLED WITH
182 2.1.4185 2.1.4
docs/maintainers.md+1−0
@@ -125,6 +125,7 @@ The following people (used to) maintain DevDocs: · 124 unmodified lines
125- [Jed Fox](https://github.com/j-f1)125- [Jed Fox](https://github.com/j-f1)
126- [Mrugesh Mohapatra](https://github.com/raisedadead)126- [Mrugesh Mohapatra](https://github.com/raisedadead)
127- [Oliver Eyton-Williams](https://github.com/ojeytonwilliams)127- [Oliver Eyton-Williams](https://github.com/ojeytonwilliams)
128- [Paul Sernatinger](https://github.com/oscillot)
128- [Simon Legner](https://github.com/simon04)129- [Simon Legner](https://github.com/simon04)
129- [Thibaut Courouble](https://github.com/thibaut)130- [Thibaut Courouble](https://github.com/thibaut)
130 131
lib/app.rb+16−1
@@ -238,7 +238,22 @@ class App < Sinatra::Application · 237 unmodified lines
238 end238 end
239 239
240 def supports_js_redirection?240 def supports_js_redirection?
241 browser.modern? && !memoized_cookies.empty?241 modern_browser?(browser) && !memoized_cookies.empty?
242 end
243
244 # https://github.com/fnando/browser#detecting-modern-browsers
245 # https://github.com/fnando/browser/blob/v2.6.1/lib/browser/browser.rb
246 # This restores the old browser gem `#modern?` functionality as it was in 2.6.1
247 # It's possible this isn't even really needed any longer, these versions are quite old now
248 def modern_browser?(browser)
249 [
250 browser.webkit?,
251 browser.firefox? && browser.version.to_i >= 17,
252 browser.ie? && browser.version.to_i >= 9 && !browser.compatibility_view?,
253 browser.edge? && !browser.compatibility_view?,
254 browser.opera? && browser.version.to_i >= 12,
255 browser.firefox? && browser.device.tablet? && browser.platform.android? && b.version.to_i >= 14
256 ].any?
242 end257 end
243 end258 end
244 259
lib/docs/core/request.rb+1−1
@@ -13,7 +13,7 @@ module Docs · 12 unmodified lines
13 request.run13 request.run
14 end14 end
15 15
16 def initialize(url, options = {})16 def initialize(url, **options)
17 super url.to_s, DEFAULT_OPTIONS.merge(options)17 super url.to_s, DEFAULT_OPTIONS.merge(options)
18 end18 end
19 19
lib/docs/core/requester.rb+8−8
@@ -4,10 +4,10 @@ module Docs · 3 unmodified lines
4 4
5 attr_reader :request_options5 attr_reader :request_options
6 6
7 def self.run(urls, options = {}, &block)7 def self.run(urls, **options, &block)
8 urls = urls.dup8 urls = urls.dup
9 requester = new(options)9 requester = new(**options)
10 requester.on_response(&block) if block10 requester.on_response(&block) if block_given?
11 requester.on_response do # cheap hack to ensure root page is processed first11 requester.on_response do # cheap hack to ensure root page is processed first
12 if urls12 if urls
13 requester.request(urls)13 requester.request(urls)
@@ -19,16 +19,16 @@ module Docs · 5 unmodified lines
19 requester19 requester
20 end20 end
21 21
22 def initialize(options = {})22 def initialize(**options)
23 @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {}23 @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {}
24 options[:max_concurrency] ||= 2024 options[:max_concurrency] ||= 20
25 options[:pipelining] = 025 options[:pipelining] = 0
26 super26 super
27 end27 end
28 28
29 def request(urls, options = {}, &block)29 def request(urls, **options, &block)
30 requests = [urls].flatten.map do |url|30 requests = [urls].flatten.map do |url|
31 build_and_queue_request(url, options, &block)31 build_and_queue_request(url, **options, &block)
32 end32 end
33 requests.length == 1 ? requests.first : requests33 requests.length == 1 ? requests.first : requests
34 end34 end
@@ -46,8 +46,8 @@ module Docs · 11 unmodified lines
46 46
47 private47 private
48 48
49 def build_and_queue_request(url, options, &block)49 def build_and_queue_request(url, **options, &block)
50 request = Request.new(url, request_options.merge(options))50 request = Request.new(url, **request_options.merge(options))
51 request.on_complete(&block) if block51 request.on_complete(&block) if block
52 queue(request)52 queue(request)
53 request53 request
lib/docs/core/scraper.rb+1−1
@@ -51,7 +51,7 @@ module Docs · 50 unmodified lines
51 end51 end
52 52
53 def initialize_stubs53 def initialize_stubs
54 self.class.stubs.each do |path, block|54 self.class.stubs.each do |path, &block|
55 Typhoeus.stub(url_for(path)).and_return do55 Typhoeus.stub(url_for(path)).and_return do
56 Typhoeus::Response.new \56 Typhoeus::Response.new \
57 effective_url: url_for(path),57 effective_url: url_for(path),
lib/tasks/updates.thor+1−1
@@ -259,7 +259,7 @@ Maintainers can close this issue when all documentations are up-to-date. The iss · 258 unmodified lines
259 # HTTP utilities259 # HTTP utilities
260 #260 #
261 261
262 def github_get(endpoint, params = {})262 def github_get(endpoint, **params)
263 github_request(endpoint, {method: :get, params: params})263 github_request(endpoint, {method: :get, params: params})
264 end264 end
265 265
test/lib/docs/core/doc_test.rb+5−5
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsDocTest < MiniTest::Spec4class DocsDocTest < MiniTest::Spec
5 let :doc do5 let :doc do
@@ -197,7 +197,7 @@ class DocsDocTest < MiniTest::Spec · 191 unmodified lines
197 it "opens the .path directory before storing the file" do197 it "opens the .path directory before storing the file" do
198 stub(doc).path { 'path' }198 stub(doc).path { 'path' }
199 stub(store).write { assert false }199 stub(store).write { assert false }
200 mock(store).open('path') do |_, block|200 mock(store).open('path') do |_, &block|
201 stub(store).write201 stub(store).write
202 block.call202 block.call
203 end203 end
@@ -258,7 +258,7 @@ class DocsDocTest < MiniTest::Spec · 54 unmodified lines
258 258
259 before do259 before do
260 any_instance_of(doc) do |instance|260 any_instance_of(doc) do |instance|
261 stub(instance).build_pages { |block| pages.each(&block) }261 stub(instance).build_pages { |&block| pages.each(&block) }
262 end262 end
263 end263 end
264 264
@@ -313,7 +313,7 @@ class DocsDocTest < MiniTest::Spec · 48 unmodified lines
313 it "replaces the .path directory before storing the files" do313 it "replaces the .path directory before storing the files" do
314 stub(doc).path { 'path' }314 stub(doc).path { 'path' }
315 stub(store).write { assert false }315 stub(store).write { assert false }
316 mock(store).replace('path') do |_, block|316 mock(store).replace('path') do |_, &block|
317 stub(store).write317 stub(store).write
318 block.call318 block.call
319 end319 end
test/lib/docs/core/entry_index_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsEntryIndexTest < MiniTest::Spec4class DocsEntryIndexTest < MiniTest::Spec
5 let :entry do5 let :entry do
test/lib/docs/core/filter_test.rb+3−3
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsFilterTest < MiniTest::Spec4class DocsFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
@@ -19,7 +19,7 @@ class DocsFilterTest < MiniTest::Spec · 13 unmodified lines
19 19
20 describe "#subpath_to" do20 describe "#subpath_to" do
21 it "returns the subpath from the #base_url to the url, ignoring case" do21 it "returns the subpath from the #base_url to the url, ignoring case" do
22 stub(filter.base_url).subpath_to('url', hash_including(ignore_case: true)) { 'subpath' }22 stub(filter.base_url).subpath_to('url', ignore_case: true) { 'subpath' }
23 assert_equal 'subpath', filter.subpath_to('url')23 assert_equal 'subpath', filter.subpath_to('url')
24 end24 end
25 end25 end
test/lib/docs/core/instrumentable_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsInstrumentableTest < MiniTest::Spec4class DocsInstrumentableTest < MiniTest::Spec
5 let :extended_class do5 let :extended_class do
test/lib/docs/core/manifest_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class ManifestTest < MiniTest::Spec4class ManifestTest < MiniTest::Spec
5 let :doc do5 let :doc do
test/lib/docs/core/models/entry_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class DocsEntryTest < MiniTest::Spec4class DocsEntryTest < MiniTest::Spec
5 Entry = Docs::Entry5 Entry = Docs::Entry
test/lib/docs/core/models/type_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class DocsTypeTest < MiniTest::Spec4class DocsTypeTest < MiniTest::Spec
5 Type = Docs::Type5 Type = Docs::Type
test/lib/docs/core/parser_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsParserTest < MiniTest::Spec4class DocsParserTest < MiniTest::Spec
5 def parser(content)5 def parser(content)
test/lib/docs/core/request_test.rb+4−4
@@ -1,13 +1,13 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsRequestTest < MiniTest::Spec4class DocsRequestTest < MiniTest::Spec
5 let :url do5 let :url do
6 'http://example.com'6 'http://example.com'
7 end7 end
8 8
9 def request(url = self.url, options = {})9 def request(url = self.url, **options)
10 Docs::Request.new(url, options).tap do |request|10 Docs::Request.new(url, **options).tap do |request|
11 request.extend FakeInstrumentation11 request.extend FakeInstrumentation
12 end12 end
13 end13 end
test/lib/docs/core/requester_test.rb+4−4
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsRequesterTest < MiniTest::Spec4class DocsRequesterTest < MiniTest::Spec
5 def stub_request(url)5 def stub_request(url)
@@ -7,7 +7,7 @@ class DocsRequesterTest < MiniTest::Spec · 1 unmodified line
7 end7 end
8 8
9 let :requester do9 let :requester do
10 Docs::Requester.new(options)10 Docs::Requester.new(**options)
11 end11 end
12 12
13 let :url do13 let :url do
@@ -81,7 +81,7 @@ class DocsRequesterTest < MiniTest::Spec · 67 unmodified lines
81 end81 end
82 82
83 it "returns an array of requests" do83 it "returns an array of requests" do
84 result = requester.request(urls, { params: 'test' }, &block)84 result = requester.request(urls, params: 'test', &block)
85 assert_instance_of Array, result85 assert_instance_of Array, result
86 assert_equal urls.length, result.length86 assert_equal urls.length, result.length
87 assert result.all? { |obj| obj.instance_of? Docs::Request }87 assert result.all? { |obj| obj.instance_of? Docs::Request }
test/lib/docs/core/response_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsResponseTest < MiniTest::Spec4class DocsResponseTest < MiniTest::Spec
5 let :response do5 let :response do
test/lib/docs/core/scraper_test.rb+3−3
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsScraperTest < MiniTest::Spec4class DocsScraperTest < MiniTest::Spec
5 class Scraper < Docs::Scraper5 class Scraper < Docs::Scraper
@@ -223,7 +223,7 @@ class DocsScraperTest < MiniTest::Spec · 217 unmodified lines
223 223
224 context "when the response is processable" do224 context "when the response is processable" do
225 before do225 before do
226 stub(scraper).request_all do |urls, block|226 stub(scraper).request_all do |urls, &block|
227 urls.each { |url| @next_urls ||= block.call(response) }227 urls.each { |url| @next_urls ||= block.call(response) }
228 end228 end
229 stub(scraper).handle_response(response) { processed_response }229 stub(scraper).handle_response(response) { processed_response }
test/lib/docs/core/scrapers/file_scraper_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class FileScraperTest < MiniTest::Spec4class FileScraperTest < MiniTest::Spec
5 ROOT_PATH = File.expand_path('../../../../../../', __FILE__)5 ROOT_PATH = File.expand_path('../../../../../../', __FILE__)
test/lib/docs/core/scrapers/url_scraper_test.rb+7−7
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class DocsUrlScraperTest < MiniTest::Spec4class DocsUrlScraperTest < MiniTest::Spec
5 class Scraper < Docs::UrlScraper5 class Scraper < Docs::UrlScraper
@@ -54,29 +54,29 @@ class DocsUrlScraperTest < MiniTest::Spec · 48 unmodified lines
54 end54 end
55 55
56 it "runs a Requester with the given urls" do56 it "runs a Requester with the given urls" do
57 mock(Docs::Requester).run 'urls', anything57 mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {"User-Agent" => "DevDocs"}})
58 result58 result
59 end59 end
60 60
61 it "runs a Requester with .headers as :request_options" do61 it "runs a Requester with .headers as :request_options" do
62 stub(Scraper).headers { { testheader: true } }62 stub(Scraper).headers { { testheader: true } }
63 mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:headers][:testheader] }63 mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {testheader: true}})
64 result64 result
65 end65 end
66 66
67 it "runs a Requester with default .headers as :request_options" do67 it "runs a Requester with default .headers as :request_options" do
68 mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:headers]["User-Agent"] }68 mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {"User-Agent" => "DevDocs"}})
69 result69 result
70 end70 end
71 71
72 it "runs a Requester with .params as :request_options" do72 it "runs a Requester with .params as :request_options" do
73 stub(Scraper).params { { test: true } }73 stub(Scraper).params { { test: true } }
74 mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:params][:test] }74 mock(Docs::Requester).run('urls', request_options: {params: {test: true}, headers: {"User-Agent" => "DevDocs"}})
75 result75 result
76 end76 end
77 77
78 it "runs a Requester with the given block" do78 it "runs a Requester with the given block" do
79 stub(Docs::Requester).run { |*args| @block = args.last }79 stub(Docs::Requester).run { |*_args, **_kwargs, &block| @block = block }
80 result80 result
81 assert_equal block, @block81 assert_equal block, @block
82 end82 end
test/lib/docs/core/url_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsUrlTest < MiniTest::Spec4class DocsUrlTest < MiniTest::Spec
5 URL = Docs::URL5 URL = Docs::URL
test/lib/docs/filters/core/apply_base_url_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class ApplyBaseUrlFilterTest < MiniTest::Spec4class ApplyBaseUrlFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/clean_html_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class CleanHtmlFilterTest < MiniTest::Spec4class CleanHtmlFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/clean_text_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class CleanTextFilterTest < MiniTest::Spec4class CleanTextFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/container_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class ContainerFilterTest < MiniTest::Spec4class ContainerFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/entries_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class EntriesFilterTest < MiniTest::Spec4class EntriesFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/inner_html_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class InnerHtmlFilterTest < MiniTest::Spec4class InnerHtmlFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/internal_urls_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class InternalUrlsFilterTest < MiniTest::Spec4class InternalUrlsFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/normalize_paths_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class NormalizePathsFilterTest < MiniTest::Spec4class NormalizePathsFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/normalize_urls_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class NormalizeUrlsFilterTest < MiniTest::Spec4class NormalizeUrlsFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/parse_cf_email_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class ParseCfEmailFilterTest < MiniTest::Spec4class ParseCfEmailFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/filters/core/title_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../../test_helper'
2require 'docs'2require_relative '../../../../../lib/docs'
3 3
4class TitleFilterTest < MiniTest::Spec4class TitleFilterTest < MiniTest::Spec
5 include FilterTestHelper5 include FilterTestHelper
test/lib/docs/storage/abstract_store_test.rb+3−3
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsAbstractStoreTest < MiniTest::Spec4class DocsAbstractStoreTest < MiniTest::Spec
5 InvalidPathError = Docs::AbstractStore::InvalidPathError5 InvalidPathError = Docs::AbstractStore::InvalidPathError
@@ -368,7 +368,7 @@ class DocsAbstractStoreTest < MiniTest::Spec · 362 unmodified lines
368 end368 end
369 369
370 def stub_paths(*paths)370 def stub_paths(*paths)
371 stub(store).each { |block| paths.each(&block) }371 stub(store).each { |&block| paths.each(&block) }
372 end372 end
373 373
374 it "calls the block" do374 it "calls the block" do
test/lib/docs/storage/file_store_test.rb+2−2
@@ -1,5 +1,5 @@
1require 'test_helper'1require_relative '../../../test_helper'
2require 'docs'2require_relative '../../../../lib/docs'
3 3
4class DocsFileStoreTest < MiniTest::Spec4class DocsFileStoreTest < MiniTest::Spec
5 let :store do5 let :store do