From 2da05d74db2b65417893746de55496d2fc86f572 Mon Sep 17 00:00:00 2001 From: Paul Sernatinger Date: Mon, 14 Nov 2022 08:30:30 -0600 Subject: [PATCH] Specs all passing --- .ruby-version | 2 +- Gemfile | 47 +++--- Gemfile.lock | 145 +++++++++--------- docs/maintainers.md | 1 + lib/app.rb | 17 +- lib/docs/core/request.rb | 2 +- lib/docs/core/requester.rb | 16 +- lib/docs/core/scraper.rb | 2 +- lib/tasks/updates.thor | 2 +- test/lib/docs/core/doc_test.rb | 10 +- test/lib/docs/core/entry_index_test.rb | 4 +- test/lib/docs/core/filter_test.rb | 6 +- test/lib/docs/core/instrumentable_test.rb | 4 +- test/lib/docs/core/manifest_test.rb | 4 +- test/lib/docs/core/models/entry_test.rb | 4 +- test/lib/docs/core/models/type_test.rb | 4 +- test/lib/docs/core/parser_test.rb | 4 +- test/lib/docs/core/request_test.rb | 8 +- test/lib/docs/core/requester_test.rb | 8 +- test/lib/docs/core/response_test.rb | 4 +- test/lib/docs/core/scraper_test.rb | 6 +- .../docs/core/scrapers/file_scraper_test.rb | 4 +- .../docs/core/scrapers/url_scraper_test.rb | 14 +- test/lib/docs/core/url_test.rb | 4 +- .../docs/filters/core/apply_base_url_test.rb | 4 +- test/lib/docs/filters/core/clean_html_test.rb | 4 +- test/lib/docs/filters/core/clean_text_test.rb | 4 +- test/lib/docs/filters/core/container_test.rb | 4 +- test/lib/docs/filters/core/entries_test.rb | 4 +- test/lib/docs/filters/core/inner_html_test.rb | 4 +- .../docs/filters/core/internal_urls_test.rb | 4 +- .../docs/filters/core/normalize_paths_test.rb | 4 +- .../docs/filters/core/normalize_urls_test.rb | 4 +- .../docs/filters/core/parse_cf_email_test.rb | 4 +- test/lib/docs/filters/core/title_test.rb | 4 +- test/lib/docs/storage/abstract_store_test.rb | 6 +- test/lib/docs/storage/file_store_test.rb | 4 +- 37 files changed, 198 insertions(+), 178 deletions(-) diff --git a/.ruby-version b/.ruby-version index 49cdd668..ef538c28 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.6 +3.1.2 diff --git a/Gemfile b/Gemfile index ee87a784..bd5c4fb4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,37 +1,38 @@ source 'https://rubygems.org' -ruby '~> 2.7.3' +ruby '3.1.2' -gem 'rake' -gem 'thor' -gem 'pry', '~> 0.14.0' -gem 'activesupport', '~> 5.2', require: false -gem 'yajl-ruby', require: false +gem 'activesupport', require: false gem 'html-pipeline' -gem 'typhoeus' gem 'nokogiri' +gem 'pry-byebug' +gem 'rake' gem 'terminal-table' +gem 'thor' +gem 'typhoeus' +gem 'yajl-ruby', require: false group :app do + gem 'browser' + gem 'chunky_png' + gem 'coffee-script' + gem 'erubi' + gem 'image_optim_pack', platforms: :ruby + gem 'image_optim' + gem 'rack-ssl-enforcer' gem 'rack' - gem 'sinatra' + gem 'rss' + gem 'sass' gem 'sinatra-contrib' - gem 'rack-ssl-enforcer' - gem 'thin' - gem 'sprockets' + gem 'sinatra' gem 'sprockets-helpers' - gem 'erubi' - gem 'browser' - gem 'sass' - gem 'coffee-script' - gem 'chunky_png' gem 'sprockets-sass' - gem 'image_optim' - gem 'image_optim_pack', platforms: :ruby + gem 'sprockets' + gem 'thin' end group :production do - gem 'uglifier' gem 'newrelic_rpm' + gem 'uglifier' end group :development do @@ -39,17 +40,17 @@ group :development do end group :docs do - gem 'redcarpet' + gem 'net-sftp', require: false gem 'progress_bar', require: false - gem 'unix_utils', require: false + gem 'redcarpet' gem 'tty-pager', require: false - gem 'net-sftp', '>= 2.1.3.rc2', require: false + gem 'unix_utils', require: false end group :test do gem 'minitest' - gem 'rr', require: false gem 'rack-test', require: false + gem 'rr', require: false end if ENV['SELENIUM'] == '1' diff --git a/Gemfile.lock b/Gemfile.lock index 63d8dc4a..25f03ef2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,136 +1,138 @@ GEM remote: https://rubygems.org/ specs: - activesupport (5.2.6) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - backports (3.15.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - browser (2.6.1) - chunky_png (1.3.11) + browser (5.3.1) + byebug (11.1.3) + chunky_png (1.4.0) coderay (1.1.3) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) - daemons (1.4.0) - erubi (1.10.0) - ethon (0.12.0) - ffi (>= 1.3.0) + concurrent-ruby (1.1.10) + daemons (1.4.1) + erubi (1.11.0) + ethon (0.16.0) + ffi (>= 1.15.0) eventmachine (1.2.7) - execjs (2.7.0) - exifr (1.3.6) + execjs (2.8.1) + exifr (1.3.10) ffi (1.15.5) fspath (3.1.2) highline (2.0.3) - html-pipeline (2.12.0) + html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) - i18n (1.8.10) + i18n (1.12.0) concurrent-ruby (~> 1.0) - image_optim (0.26.5) + image_optim (0.31.1) exifr (~> 1.2, >= 1.2.2) fspath (~> 3.0) - image_size (>= 1.5, < 3) + image_size (>= 1.5, < 4) in_threads (~> 1.3) progress (~> 3.0, >= 3.0.1) - image_optim_pack (0.6.0) + image_optim_pack (0.9.1.20221104) fspath (>= 2.1, < 4) image_optim (~> 0.19) - image_size (2.0.2) - in_threads (1.5.3) + image_size (3.2.0) + in_threads (1.6.0) method_source (1.0.0) mini_portile2 (2.8.0) - minitest (5.14.4) - multi_json (1.13.1) - mustermann (1.1.1) + minitest (5.16.3) + multi_json (1.15.0) + mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - net-sftp (3.0.0.beta1) - net-ssh (>= 5.0.0, < 6.0.0) - net-ssh (5.2.0) - newrelic_rpm (6.7.0.359) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-ssh (7.0.1) + newrelic_rpm (8.12.0) nokogiri (1.13.9) mini_portile2 (~> 2.8.0) racc (~> 1.4) options (2.3.2) - progress (3.5.2) - progress_bar (1.3.0) + progress (3.6.0) + progress_bar (1.3.3) highline (>= 1.6, < 3) options (~> 2.3.0) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) racc (1.6.0) - rack (2.2.3.1) - rack-protection (2.0.7) + rack (2.2.4) + rack-protection (3.0.3) rack rack-ssl-enforcer (0.2.9) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rake (13.0.0) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rack-test (2.0.2) + rack (>= 1.3) + rake (13.0.6) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) ffi (~> 1.0) redcarpet (3.5.1) - rr (1.2.1) + rexml (3.2.5) + rr (3.1.0) + rss (0.2.9) + rexml ruby2_keywords (0.0.5) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sinatra (2.0.7) - mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + sinatra (3.0.3) + mustermann (~> 3.0) + rack (~> 2.2, >= 2.2.4) + rack-protection (= 3.0.3) tilt (~> 2.0) - sinatra-contrib (2.0.7) - backports (>= 2.8.2) + sinatra-contrib (3.0.3) multi_json - mustermann (~> 1.0) - rack-protection (= 2.0.7) - sinatra (= 2.0.7) + mustermann (~> 3.0) + rack-protection (= 3.0.3) + sinatra (= 3.0.3) tilt (~> 2.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-helpers (1.2.1) + sprockets-helpers (1.4.0) sprockets (>= 2.2) sprockets-sass (2.0.0.beta2) sprockets (>= 2.0, < 4.0) - strings (0.1.6) - strings-ansi (~> 0.1) - unicode-display_width (~> 1.5) + strings (0.2.1) + strings-ansi (~> 0.2) + unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) - strings-ansi (0.1.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) + strings-ansi (0.2.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) thin (1.8.1) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.20.3) - thread_safe (0.3.6) - tilt (2.0.10) - tty-pager (0.12.1) - strings (~> 0.1.4) - tty-screen (~> 0.6) - tty-which (~> 0.4) - tty-screen (0.7.0) - tty-which (0.4.1) - typhoeus (1.3.1) + thor (1.2.1) + tilt (2.0.11) + tty-pager (0.14.0) + strings (~> 0.2.0) + tty-screen (~> 0.8) + tty-screen (0.8.1) + typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.10) - thread_safe (~> 0.1) + tzinfo (2.0.5) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.0) + unicode-display_width (2.3.0) unicode_utils (1.4.0) unix_utils (0.0.15) yajl-ruby (1.4.3) @@ -139,7 +141,7 @@ PLATFORMS ruby DEPENDENCIES - activesupport (~> 5.2) + activesupport better_errors browser chunky_png @@ -149,17 +151,18 @@ DEPENDENCIES image_optim image_optim_pack minitest - net-sftp (>= 2.1.3.rc2) + net-sftp newrelic_rpm nokogiri progress_bar - pry (~> 0.14.0) + pry-byebug rack rack-ssl-enforcer rack-test rake redcarpet rr + rss sass sinatra sinatra-contrib @@ -176,7 +179,7 @@ DEPENDENCIES yajl-ruby RUBY VERSION - ruby 2.7.3p183 + ruby 3.1.2p20 BUNDLED WITH 2.1.4 diff --git a/docs/maintainers.md b/docs/maintainers.md index e8483a41..24436b73 100644 --- a/docs/maintainers.md +++ b/docs/maintainers.md @@ -125,6 +125,7 @@ The following people (used to) maintain DevDocs: - [Jed Fox](https://github.com/j-f1) - [Mrugesh Mohapatra](https://github.com/raisedadead) - [Oliver Eyton-Williams](https://github.com/ojeytonwilliams) +- [Paul Sernatinger](https://github.com/oscillot) - [Simon Legner](https://github.com/simon04) - [Thibaut Courouble](https://github.com/thibaut) diff --git a/lib/app.rb b/lib/app.rb index 43ce2a4e..6d197b4a 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -238,7 +238,22 @@ class App < Sinatra::Application end def supports_js_redirection? - browser.modern? && !memoized_cookies.empty? + modern_browser?(browser) && !memoized_cookies.empty? + end + + # https://github.com/fnando/browser#detecting-modern-browsers + # https://github.com/fnando/browser/blob/v2.6.1/lib/browser/browser.rb + # This restores the old browser gem `#modern?` functionality as it was in 2.6.1 + # It's possible this isn't even really needed any longer, these versions are quite old now + def modern_browser?(browser) + [ + browser.webkit?, + browser.firefox? && browser.version.to_i >= 17, + browser.ie? && browser.version.to_i >= 9 && !browser.compatibility_view?, + browser.edge? && !browser.compatibility_view?, + browser.opera? && browser.version.to_i >= 12, + browser.firefox? && browser.device.tablet? && browser.platform.android? && b.version.to_i >= 14 + ].any? end end diff --git a/lib/docs/core/request.rb b/lib/docs/core/request.rb index b1e26e68..2a7f96c6 100644 --- a/lib/docs/core/request.rb +++ b/lib/docs/core/request.rb @@ -13,7 +13,7 @@ module Docs request.run end - def initialize(url, options = {}) + def initialize(url, **options) super url.to_s, DEFAULT_OPTIONS.merge(options) end diff --git a/lib/docs/core/requester.rb b/lib/docs/core/requester.rb index 6c7f5b6a..ed8bafcb 100644 --- a/lib/docs/core/requester.rb +++ b/lib/docs/core/requester.rb @@ -4,10 +4,10 @@ module Docs attr_reader :request_options - def self.run(urls, options = {}, &block) + def self.run(urls, **options, &block) urls = urls.dup - requester = new(options) - requester.on_response(&block) if block + requester = new(**options) + requester.on_response(&block) if block_given? requester.on_response do # cheap hack to ensure root page is processed first if urls requester.request(urls) @@ -19,16 +19,16 @@ module Docs requester end - def initialize(options = {}) + def initialize(**options) @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {} options[:max_concurrency] ||= 20 options[:pipelining] = 0 super end - def request(urls, options = {}, &block) + def request(urls, **options, &block) requests = [urls].flatten.map do |url| - build_and_queue_request(url, options, &block) + build_and_queue_request(url, **options, &block) end requests.length == 1 ? requests.first : requests end @@ -46,8 +46,8 @@ module Docs private - def build_and_queue_request(url, options, &block) - request = Request.new(url, request_options.merge(options)) + def build_and_queue_request(url, **options, &block) + request = Request.new(url, **request_options.merge(options)) request.on_complete(&block) if block queue(request) request diff --git a/lib/docs/core/scraper.rb b/lib/docs/core/scraper.rb index 083b0015..007580ed 100644 --- a/lib/docs/core/scraper.rb +++ b/lib/docs/core/scraper.rb @@ -51,7 +51,7 @@ module Docs end def initialize_stubs - self.class.stubs.each do |path, block| + self.class.stubs.each do |path, &block| Typhoeus.stub(url_for(path)).and_return do Typhoeus::Response.new \ effective_url: url_for(path), diff --git a/lib/tasks/updates.thor b/lib/tasks/updates.thor index 62dcf20c..5dd15397 100644 --- a/lib/tasks/updates.thor +++ b/lib/tasks/updates.thor @@ -259,7 +259,7 @@ Maintainers can close this issue when all documentations are up-to-date. The iss # HTTP utilities # - def github_get(endpoint, params = {}) + def github_get(endpoint, **params) github_request(endpoint, {method: :get, params: params}) end diff --git a/test/lib/docs/core/doc_test.rb b/test/lib/docs/core/doc_test.rb index 3da1fcfc..b0d2341f 100644 --- a/test/lib/docs/core/doc_test.rb +++ b/test/lib/docs/core/doc_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsDocTest < MiniTest::Spec let :doc do @@ -197,7 +197,7 @@ class DocsDocTest < MiniTest::Spec it "opens the .path directory before storing the file" do stub(doc).path { 'path' } stub(store).write { assert false } - mock(store).open('path') do |_, block| + mock(store).open('path') do |_, &block| stub(store).write block.call end @@ -258,7 +258,7 @@ class DocsDocTest < MiniTest::Spec before do any_instance_of(doc) do |instance| - stub(instance).build_pages { |block| pages.each(&block) } + stub(instance).build_pages { |&block| pages.each(&block) } end end @@ -313,7 +313,7 @@ class DocsDocTest < MiniTest::Spec it "replaces the .path directory before storing the files" do stub(doc).path { 'path' } stub(store).write { assert false } - mock(store).replace('path') do |_, block| + mock(store).replace('path') do |_, &block| stub(store).write block.call end diff --git a/test/lib/docs/core/entry_index_test.rb b/test/lib/docs/core/entry_index_test.rb index 0f8b0b18..187f5f4a 100644 --- a/test/lib/docs/core/entry_index_test.rb +++ b/test/lib/docs/core/entry_index_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsEntryIndexTest < MiniTest::Spec let :entry do diff --git a/test/lib/docs/core/filter_test.rb b/test/lib/docs/core/filter_test.rb index 77265c22..38c5019a 100644 --- a/test/lib/docs/core/filter_test.rb +++ b/test/lib/docs/core/filter_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsFilterTest < MiniTest::Spec include FilterTestHelper @@ -19,7 +19,7 @@ class DocsFilterTest < MiniTest::Spec describe "#subpath_to" do it "returns the subpath from the #base_url to the url, ignoring case" do - stub(filter.base_url).subpath_to('url', hash_including(ignore_case: true)) { 'subpath' } + stub(filter.base_url).subpath_to('url', ignore_case: true) { 'subpath' } assert_equal 'subpath', filter.subpath_to('url') end end diff --git a/test/lib/docs/core/instrumentable_test.rb b/test/lib/docs/core/instrumentable_test.rb index 0c8fc956..c3fe2b8b 100644 --- a/test/lib/docs/core/instrumentable_test.rb +++ b/test/lib/docs/core/instrumentable_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsInstrumentableTest < MiniTest::Spec let :extended_class do diff --git a/test/lib/docs/core/manifest_test.rb b/test/lib/docs/core/manifest_test.rb index 16484a70..583b2cee 100644 --- a/test/lib/docs/core/manifest_test.rb +++ b/test/lib/docs/core/manifest_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class ManifestTest < MiniTest::Spec let :doc do diff --git a/test/lib/docs/core/models/entry_test.rb b/test/lib/docs/core/models/entry_test.rb index 307cdaac..7487340f 100644 --- a/test/lib/docs/core/models/entry_test.rb +++ b/test/lib/docs/core/models/entry_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class DocsEntryTest < MiniTest::Spec Entry = Docs::Entry diff --git a/test/lib/docs/core/models/type_test.rb b/test/lib/docs/core/models/type_test.rb index 8d95ea36..a01d8e61 100644 --- a/test/lib/docs/core/models/type_test.rb +++ b/test/lib/docs/core/models/type_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class DocsTypeTest < MiniTest::Spec Type = Docs::Type diff --git a/test/lib/docs/core/parser_test.rb b/test/lib/docs/core/parser_test.rb index 21f62c39..440516a8 100644 --- a/test/lib/docs/core/parser_test.rb +++ b/test/lib/docs/core/parser_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsParserTest < MiniTest::Spec def parser(content) diff --git a/test/lib/docs/core/request_test.rb b/test/lib/docs/core/request_test.rb index a5a9e48c..d05dd1ff 100644 --- a/test/lib/docs/core/request_test.rb +++ b/test/lib/docs/core/request_test.rb @@ -1,13 +1,13 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsRequestTest < MiniTest::Spec let :url do 'http://example.com' end - def request(url = self.url, options = {}) - Docs::Request.new(url, options).tap do |request| + def request(url = self.url, **options) + Docs::Request.new(url, **options).tap do |request| request.extend FakeInstrumentation end end diff --git a/test/lib/docs/core/requester_test.rb b/test/lib/docs/core/requester_test.rb index 63eace1a..acf8d0a9 100644 --- a/test/lib/docs/core/requester_test.rb +++ b/test/lib/docs/core/requester_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsRequesterTest < MiniTest::Spec def stub_request(url) @@ -7,7 +7,7 @@ class DocsRequesterTest < MiniTest::Spec end let :requester do - Docs::Requester.new(options) + Docs::Requester.new(**options) end let :url do @@ -81,7 +81,7 @@ class DocsRequesterTest < MiniTest::Spec end it "returns an array of requests" do - result = requester.request(urls, { params: 'test' }, &block) + result = requester.request(urls, params: 'test', &block) assert_instance_of Array, result assert_equal urls.length, result.length assert result.all? { |obj| obj.instance_of? Docs::Request } diff --git a/test/lib/docs/core/response_test.rb b/test/lib/docs/core/response_test.rb index 4142752d..9e92c034 100644 --- a/test/lib/docs/core/response_test.rb +++ b/test/lib/docs/core/response_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsResponseTest < MiniTest::Spec let :response do diff --git a/test/lib/docs/core/scraper_test.rb b/test/lib/docs/core/scraper_test.rb index 25e0af3b..3d493207 100644 --- a/test/lib/docs/core/scraper_test.rb +++ b/test/lib/docs/core/scraper_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsScraperTest < MiniTest::Spec class Scraper < Docs::Scraper @@ -223,7 +223,7 @@ class DocsScraperTest < MiniTest::Spec context "when the response is processable" do before do - stub(scraper).request_all do |urls, block| + stub(scraper).request_all do |urls, &block| urls.each { |url| @next_urls ||= block.call(response) } end stub(scraper).handle_response(response) { processed_response } diff --git a/test/lib/docs/core/scrapers/file_scraper_test.rb b/test/lib/docs/core/scrapers/file_scraper_test.rb index 88b5e8d5..46dad3c7 100644 --- a/test/lib/docs/core/scrapers/file_scraper_test.rb +++ b/test/lib/docs/core/scrapers/file_scraper_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class FileScraperTest < MiniTest::Spec ROOT_PATH = File.expand_path('../../../../../../', __FILE__) diff --git a/test/lib/docs/core/scrapers/url_scraper_test.rb b/test/lib/docs/core/scrapers/url_scraper_test.rb index 5ff72231..9a687256 100644 --- a/test/lib/docs/core/scrapers/url_scraper_test.rb +++ b/test/lib/docs/core/scrapers/url_scraper_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class DocsUrlScraperTest < MiniTest::Spec class Scraper < Docs::UrlScraper @@ -54,29 +54,29 @@ class DocsUrlScraperTest < MiniTest::Spec end it "runs a Requester with the given urls" do - mock(Docs::Requester).run 'urls', anything + mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {"User-Agent" => "DevDocs"}}) result end it "runs a Requester with .headers as :request_options" do stub(Scraper).headers { { testheader: true } } - mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:headers][:testheader] } + mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {testheader: true}}) result end it "runs a Requester with default .headers as :request_options" do - mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:headers]["User-Agent"] } + mock(Docs::Requester).run('urls', request_options: {params: {}, headers: {"User-Agent" => "DevDocs"}}) result end it "runs a Requester with .params as :request_options" do stub(Scraper).params { { test: true } } - mock(Docs::Requester).run anything, satisfy { |options| options[:request_options][:params][:test] } + mock(Docs::Requester).run('urls', request_options: {params: {test: true}, headers: {"User-Agent" => "DevDocs"}}) result end it "runs a Requester with the given block" do - stub(Docs::Requester).run { |*args| @block = args.last } + stub(Docs::Requester).run { |*_args, **_kwargs, &block| @block = block } result assert_equal block, @block end diff --git a/test/lib/docs/core/url_test.rb b/test/lib/docs/core/url_test.rb index 08839b54..7d4bda43 100644 --- a/test/lib/docs/core/url_test.rb +++ b/test/lib/docs/core/url_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsUrlTest < MiniTest::Spec URL = Docs::URL diff --git a/test/lib/docs/filters/core/apply_base_url_test.rb b/test/lib/docs/filters/core/apply_base_url_test.rb index e627d959..ba2764e7 100644 --- a/test/lib/docs/filters/core/apply_base_url_test.rb +++ b/test/lib/docs/filters/core/apply_base_url_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class ApplyBaseUrlFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/clean_html_test.rb b/test/lib/docs/filters/core/clean_html_test.rb index a3e163e0..2d3c9f8a 100644 --- a/test/lib/docs/filters/core/clean_html_test.rb +++ b/test/lib/docs/filters/core/clean_html_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class CleanHtmlFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/clean_text_test.rb b/test/lib/docs/filters/core/clean_text_test.rb index ec08b6e6..7babf15e 100644 --- a/test/lib/docs/filters/core/clean_text_test.rb +++ b/test/lib/docs/filters/core/clean_text_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class CleanTextFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/container_test.rb b/test/lib/docs/filters/core/container_test.rb index cdf08c0d..7d4993e8 100644 --- a/test/lib/docs/filters/core/container_test.rb +++ b/test/lib/docs/filters/core/container_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class ContainerFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/entries_test.rb b/test/lib/docs/filters/core/entries_test.rb index 0fa843a0..e33f778d 100644 --- a/test/lib/docs/filters/core/entries_test.rb +++ b/test/lib/docs/filters/core/entries_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class EntriesFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/inner_html_test.rb b/test/lib/docs/filters/core/inner_html_test.rb index 194cc555..bbd40958 100644 --- a/test/lib/docs/filters/core/inner_html_test.rb +++ b/test/lib/docs/filters/core/inner_html_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class InnerHtmlFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/internal_urls_test.rb b/test/lib/docs/filters/core/internal_urls_test.rb index 5d9df469..c9194e09 100644 --- a/test/lib/docs/filters/core/internal_urls_test.rb +++ b/test/lib/docs/filters/core/internal_urls_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class InternalUrlsFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/normalize_paths_test.rb b/test/lib/docs/filters/core/normalize_paths_test.rb index b3fc120d..6d407f2b 100644 --- a/test/lib/docs/filters/core/normalize_paths_test.rb +++ b/test/lib/docs/filters/core/normalize_paths_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class NormalizePathsFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/normalize_urls_test.rb b/test/lib/docs/filters/core/normalize_urls_test.rb index 7e2a56e5..804b05b1 100644 --- a/test/lib/docs/filters/core/normalize_urls_test.rb +++ b/test/lib/docs/filters/core/normalize_urls_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class NormalizeUrlsFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/parse_cf_email_test.rb b/test/lib/docs/filters/core/parse_cf_email_test.rb index ed0a9229..d6124fed 100644 --- a/test/lib/docs/filters/core/parse_cf_email_test.rb +++ b/test/lib/docs/filters/core/parse_cf_email_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class ParseCfEmailFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/filters/core/title_test.rb b/test/lib/docs/filters/core/title_test.rb index 69c83fe3..9a28bd3b 100644 --- a/test/lib/docs/filters/core/title_test.rb +++ b/test/lib/docs/filters/core/title_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../../test_helper' +require_relative '../../../../../lib/docs' class TitleFilterTest < MiniTest::Spec include FilterTestHelper diff --git a/test/lib/docs/storage/abstract_store_test.rb b/test/lib/docs/storage/abstract_store_test.rb index f552cd4a..d63e95f2 100644 --- a/test/lib/docs/storage/abstract_store_test.rb +++ b/test/lib/docs/storage/abstract_store_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsAbstractStoreTest < MiniTest::Spec InvalidPathError = Docs::AbstractStore::InvalidPathError @@ -368,7 +368,7 @@ class DocsAbstractStoreTest < MiniTest::Spec end def stub_paths(*paths) - stub(store).each { |block| paths.each(&block) } + stub(store).each { |&block| paths.each(&block) } end it "calls the block" do diff --git a/test/lib/docs/storage/file_store_test.rb b/test/lib/docs/storage/file_store_test.rb index 586d8a41..aa3ce3f8 100644 --- a/test/lib/docs/storage/file_store_test.rb +++ b/test/lib/docs/storage/file_store_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'docs' +require_relative '../../../test_helper' +require_relative '../../../../lib/docs' class DocsFileStoreTest < MiniTest::Spec let :store do