Specs all passing

pull/1867/head
Paul Sernatinger 2 years ago
parent b3e55ed791
commit 2da05d74db

@ -1 +1 @@
2.7.6 3.1.2

@ -1,37 +1,38 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '~> 2.7.3' ruby '3.1.2'
gem 'rake' gem 'activesupport', require: false
gem 'thor'
gem 'pry', '~> 0.14.0'
gem 'activesupport', '~> 5.2', require: false
gem 'yajl-ruby', require: false
gem 'html-pipeline' gem 'html-pipeline'
gem 'typhoeus'
gem 'nokogiri' gem 'nokogiri'
gem 'pry-byebug'
gem 'rake'
gem 'terminal-table' gem 'terminal-table'
gem 'thor'
gem 'typhoeus'
gem 'yajl-ruby', require: false
group :app do 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 'rack'
gem 'sinatra' gem 'rss'
gem 'sass'
gem 'sinatra-contrib' gem 'sinatra-contrib'
gem 'rack-ssl-enforcer' gem 'sinatra'
gem 'thin'
gem 'sprockets'
gem 'sprockets-helpers' gem 'sprockets-helpers'
gem 'erubi'
gem 'browser'
gem 'sass'
gem 'coffee-script'
gem 'chunky_png'
gem 'sprockets-sass' gem 'sprockets-sass'
gem 'image_optim' gem 'sprockets'
gem 'image_optim_pack', platforms: :ruby gem 'thin'
end end
group :production do group :production do
gem 'uglifier'
gem 'newrelic_rpm' gem 'newrelic_rpm'
gem 'uglifier'
end end
group :development do group :development do
@ -39,17 +40,17 @@ group :development do
end end
group :docs do group :docs do
gem 'redcarpet' gem 'net-sftp', require: false
gem 'progress_bar', require: false gem 'progress_bar', require: false
gem 'unix_utils', require: false gem 'redcarpet'
gem 'tty-pager', require: false gem 'tty-pager', require: false
gem 'net-sftp', '>= 2.1.3.rc2', require: false gem 'unix_utils', require: false
end end
group :test do group :test do
gem 'minitest' gem 'minitest'
gem 'rr', require: false
gem 'rack-test', require: false gem 'rack-test', require: false
gem 'rr', require: false
end end
if ENV['SELENIUM'] == '1' if ENV['SELENIUM'] == '1'

@ -1,136 +1,138 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (5.2.6) activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 1.6, < 2)
minitest (~> 5.1) minitest (>= 5.1)
tzinfo (~> 1.1) tzinfo (~> 2.0)
backports (3.15.0)
better_errors (2.9.1) better_errors (2.9.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubi (>= 1.0.0) erubi (>= 1.0.0)
rack (>= 0.9.0) rack (>= 0.9.0)
browser (2.6.1) browser (5.3.1)
chunky_png (1.3.11) byebug (11.1.3)
chunky_png (1.4.0)
coderay (1.1.3) coderay (1.1.3)
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.10)
daemons (1.4.0) daemons (1.4.1)
erubi (1.10.0) erubi (1.11.0)
ethon (0.12.0) ethon (0.16.0)
ffi (>= 1.3.0) ffi (>= 1.15.0)
eventmachine (1.2.7) eventmachine (1.2.7)
execjs (2.7.0) execjs (2.8.1)
exifr (1.3.6) exifr (1.3.10)
ffi (1.15.5) ffi (1.15.5)
fspath (3.1.2) fspath (3.1.2)
highline (2.0.3) highline (2.0.3)
html-pipeline (2.12.0) html-pipeline (2.14.3)
activesupport (>= 2) activesupport (>= 2)
nokogiri (>= 1.4) nokogiri (>= 1.4)
i18n (1.8.10) i18n (1.12.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
image_optim (0.26.5) image_optim (0.31.1)
exifr (~> 1.2, >= 1.2.2) exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0) fspath (~> 3.0)
image_size (>= 1.5, < 3) image_size (>= 1.5, < 4)
in_threads (~> 1.3) in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1) progress (~> 3.0, >= 3.0.1)
image_optim_pack (0.6.0) image_optim_pack (0.9.1.20221104)
fspath (>= 2.1, < 4) fspath (>= 2.1, < 4)
image_optim (~> 0.19) image_optim (~> 0.19)
image_size (2.0.2) image_size (3.2.0)
in_threads (1.5.3) in_threads (1.6.0)
method_source (1.0.0) method_source (1.0.0)
mini_portile2 (2.8.0) mini_portile2 (2.8.0)
minitest (5.14.4) minitest (5.16.3)
multi_json (1.13.1) multi_json (1.15.0)
mustermann (1.1.1) mustermann (3.0.0)
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
net-sftp (3.0.0.beta1) net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 6.0.0) net-ssh (>= 5.0.0, < 8.0.0)
net-ssh (5.2.0) net-ssh (7.0.1)
newrelic_rpm (6.7.0.359) newrelic_rpm (8.12.0)
nokogiri (1.13.9) nokogiri (1.13.9)
mini_portile2 (~> 2.8.0) mini_portile2 (~> 2.8.0)
racc (~> 1.4) racc (~> 1.4)
options (2.3.2) options (2.3.2)
progress (3.5.2) progress (3.6.0)
progress_bar (1.3.0) progress_bar (1.3.3)
highline (>= 1.6, < 3) highline (>= 1.6, < 3)
options (~> 2.3.0) options (~> 2.3.0)
pry (0.14.1) pry (0.14.1)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.6.0) racc (1.6.0)
rack (2.2.3.1) rack (2.2.4)
rack-protection (2.0.7) rack-protection (3.0.3)
rack rack
rack-ssl-enforcer (0.2.9) rack-ssl-enforcer (0.2.9)
rack-test (1.1.0) rack-test (2.0.2)
rack (>= 1.0, < 3) rack (>= 1.3)
rake (13.0.0) rake (13.0.6)
rb-fsevent (0.10.3) rb-fsevent (0.11.2)
rb-inotify (0.10.0) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
redcarpet (3.5.1) 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) ruby2_keywords (0.0.5)
sass (3.7.4) sass (3.7.4)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
sinatra (2.0.7) sinatra (3.0.3)
mustermann (~> 1.0) mustermann (~> 3.0)
rack (~> 2.0) rack (~> 2.2, >= 2.2.4)
rack-protection (= 2.0.7) rack-protection (= 3.0.3)
tilt (~> 2.0) tilt (~> 2.0)
sinatra-contrib (2.0.7) sinatra-contrib (3.0.3)
backports (>= 2.8.2)
multi_json multi_json
mustermann (~> 1.0) mustermann (~> 3.0)
rack-protection (= 2.0.7) rack-protection (= 3.0.3)
sinatra (= 2.0.7) sinatra (= 3.0.3)
tilt (~> 2.0) tilt (~> 2.0)
sprockets (3.7.2) sprockets (3.7.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-helpers (1.2.1) sprockets-helpers (1.4.0)
sprockets (>= 2.2) sprockets (>= 2.2)
sprockets-sass (2.0.0.beta2) sprockets-sass (2.0.0.beta2)
sprockets (>= 2.0, < 4.0) sprockets (>= 2.0, < 4.0)
strings (0.1.6) strings (0.2.1)
strings-ansi (~> 0.1) strings-ansi (~> 0.2)
unicode-display_width (~> 1.5) unicode-display_width (>= 1.5, < 3.0)
unicode_utils (~> 1.4) unicode_utils (~> 1.4)
strings-ansi (0.1.0) strings-ansi (0.2.0)
terminal-table (1.8.0) terminal-table (3.0.2)
unicode-display_width (~> 1.1, >= 1.1.1) unicode-display_width (>= 1.1.1, < 3)
thin (1.8.1) thin (1.8.1)
daemons (~> 1.0, >= 1.0.9) daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4) eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3) rack (>= 1, < 3)
thor (0.20.3) thor (1.2.1)
thread_safe (0.3.6) tilt (2.0.11)
tilt (2.0.10) tty-pager (0.14.0)
tty-pager (0.12.1) strings (~> 0.2.0)
strings (~> 0.1.4) tty-screen (~> 0.8)
tty-screen (~> 0.6) tty-screen (0.8.1)
tty-which (~> 0.4) typhoeus (1.4.0)
tty-screen (0.7.0)
tty-which (0.4.1)
typhoeus (1.3.1)
ethon (>= 0.9.0) ethon (>= 0.9.0)
tzinfo (1.2.10) tzinfo (2.0.5)
thread_safe (~> 0.1) concurrent-ruby (~> 1.0)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unicode-display_width (1.6.0) unicode-display_width (2.3.0)
unicode_utils (1.4.0) unicode_utils (1.4.0)
unix_utils (0.0.15) unix_utils (0.0.15)
yajl-ruby (1.4.3) yajl-ruby (1.4.3)
@ -139,7 +141,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activesupport (~> 5.2) activesupport
better_errors better_errors
browser browser
chunky_png chunky_png
@ -149,17 +151,18 @@ DEPENDENCIES
image_optim image_optim
image_optim_pack image_optim_pack
minitest minitest
net-sftp (>= 2.1.3.rc2) net-sftp
newrelic_rpm newrelic_rpm
nokogiri nokogiri
progress_bar progress_bar
pry (~> 0.14.0) pry-byebug
rack rack
rack-ssl-enforcer rack-ssl-enforcer
rack-test rack-test
rake rake
redcarpet redcarpet
rr rr
rss
sass sass
sinatra sinatra
sinatra-contrib sinatra-contrib
@ -176,7 +179,7 @@ DEPENDENCIES
yajl-ruby yajl-ruby
RUBY VERSION RUBY VERSION
ruby 2.7.3p183 ruby 3.1.2p20
BUNDLED WITH BUNDLED WITH
2.1.4 2.1.4

@ -125,6 +125,7 @@ The following people (used to) maintain DevDocs:
- [Jed Fox](https://github.com/j-f1) - [Jed Fox](https://github.com/j-f1)
- [Mrugesh Mohapatra](https://github.com/raisedadead) - [Mrugesh Mohapatra](https://github.com/raisedadead)
- [Oliver Eyton-Williams](https://github.com/ojeytonwilliams) - [Oliver Eyton-Williams](https://github.com/ojeytonwilliams)
- [Paul Sernatinger](https://github.com/oscillot)
- [Simon Legner](https://github.com/simon04) - [Simon Legner](https://github.com/simon04)
- [Thibaut Courouble](https://github.com/thibaut) - [Thibaut Courouble](https://github.com/thibaut)

@ -238,7 +238,22 @@ class App < Sinatra::Application
end end
def supports_js_redirection? 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
end end

@ -13,7 +13,7 @@ module Docs
request.run request.run
end end
def initialize(url, options = {}) def initialize(url, **options)
super url.to_s, DEFAULT_OPTIONS.merge(options) super url.to_s, DEFAULT_OPTIONS.merge(options)
end end

@ -4,10 +4,10 @@ module Docs
attr_reader :request_options attr_reader :request_options
def self.run(urls, options = {}, &block) def self.run(urls, **options, &block)
urls = urls.dup urls = urls.dup
requester = new(options) requester = new(**options)
requester.on_response(&block) if block requester.on_response(&block) if block_given?
requester.on_response do # cheap hack to ensure root page is processed first requester.on_response do # cheap hack to ensure root page is processed first
if urls if urls
requester.request(urls) requester.request(urls)
@ -19,16 +19,16 @@ module Docs
requester requester
end end
def initialize(options = {}) def initialize(**options)
@request_options = options.extract!(:request_options)[:request_options].try(:dup) || {} @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {}
options[:max_concurrency] ||= 20 options[:max_concurrency] ||= 20
options[:pipelining] = 0 options[:pipelining] = 0
super super
end end
def request(urls, options = {}, &block) def request(urls, **options, &block)
requests = [urls].flatten.map do |url| requests = [urls].flatten.map do |url|
build_and_queue_request(url, options, &block) build_and_queue_request(url, **options, &block)
end end
requests.length == 1 ? requests.first : requests requests.length == 1 ? requests.first : requests
end end
@ -46,8 +46,8 @@ module Docs
private private
def build_and_queue_request(url, options, &block) def build_and_queue_request(url, **options, &block)
request = Request.new(url, request_options.merge(options)) request = Request.new(url, **request_options.merge(options))
request.on_complete(&block) if block request.on_complete(&block) if block
queue(request) queue(request)
request request

@ -51,7 +51,7 @@ module Docs
end end
def initialize_stubs 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.stub(url_for(path)).and_return do
Typhoeus::Response.new \ Typhoeus::Response.new \
effective_url: url_for(path), effective_url: url_for(path),

@ -259,7 +259,7 @@ Maintainers can close this issue when all documentations are up-to-date. The iss
# HTTP utilities # HTTP utilities
# #
def github_get(endpoint, params = {}) def github_get(endpoint, **params)
github_request(endpoint, {method: :get, params: params}) github_request(endpoint, {method: :get, params: params})
end end

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsDocTest < MiniTest::Spec class DocsDocTest < MiniTest::Spec
let :doc do let :doc do
@ -197,7 +197,7 @@ class DocsDocTest < MiniTest::Spec
it "opens the .path directory before storing the file" do it "opens the .path directory before storing the file" do
stub(doc).path { 'path' } stub(doc).path { 'path' }
stub(store).write { assert false } stub(store).write { assert false }
mock(store).open('path') do |_, block| mock(store).open('path') do |_, &block|
stub(store).write stub(store).write
block.call block.call
end end
@ -258,7 +258,7 @@ class DocsDocTest < MiniTest::Spec
before do before do
any_instance_of(doc) do |instance| any_instance_of(doc) do |instance|
stub(instance).build_pages { |block| pages.each(&block) } stub(instance).build_pages { |&block| pages.each(&block) }
end end
end end
@ -313,7 +313,7 @@ class DocsDocTest < MiniTest::Spec
it "replaces the .path directory before storing the files" do it "replaces the .path directory before storing the files" do
stub(doc).path { 'path' } stub(doc).path { 'path' }
stub(store).write { assert false } stub(store).write { assert false }
mock(store).replace('path') do |_, block| mock(store).replace('path') do |_, &block|
stub(store).write stub(store).write
block.call block.call
end end

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsEntryIndexTest < MiniTest::Spec class DocsEntryIndexTest < MiniTest::Spec
let :entry do let :entry do

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsFilterTest < MiniTest::Spec class DocsFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper
@ -19,7 +19,7 @@ class DocsFilterTest < MiniTest::Spec
describe "#subpath_to" do describe "#subpath_to" do
it "returns the subpath from the #base_url to the url, ignoring case" 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') assert_equal 'subpath', filter.subpath_to('url')
end end
end end

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsInstrumentableTest < MiniTest::Spec class DocsInstrumentableTest < MiniTest::Spec
let :extended_class do let :extended_class do

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class ManifestTest < MiniTest::Spec class ManifestTest < MiniTest::Spec
let :doc do let :doc do

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class DocsEntryTest < MiniTest::Spec class DocsEntryTest < MiniTest::Spec
Entry = Docs::Entry Entry = Docs::Entry

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class DocsTypeTest < MiniTest::Spec class DocsTypeTest < MiniTest::Spec
Type = Docs::Type Type = Docs::Type

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsParserTest < MiniTest::Spec class DocsParserTest < MiniTest::Spec
def parser(content) def parser(content)

@ -1,13 +1,13 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsRequestTest < MiniTest::Spec class DocsRequestTest < MiniTest::Spec
let :url do let :url do
'http://example.com' 'http://example.com'
end end
def request(url = self.url, options = {}) def request(url = self.url, **options)
Docs::Request.new(url, options).tap do |request| Docs::Request.new(url, **options).tap do |request|
request.extend FakeInstrumentation request.extend FakeInstrumentation
end end
end end

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsRequesterTest < MiniTest::Spec class DocsRequesterTest < MiniTest::Spec
def stub_request(url) def stub_request(url)
@ -7,7 +7,7 @@ class DocsRequesterTest < MiniTest::Spec
end end
let :requester do let :requester do
Docs::Requester.new(options) Docs::Requester.new(**options)
end end
let :url do let :url do
@ -81,7 +81,7 @@ class DocsRequesterTest < MiniTest::Spec
end end
it "returns an array of requests" do 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_instance_of Array, result
assert_equal urls.length, result.length assert_equal urls.length, result.length
assert result.all? { |obj| obj.instance_of? Docs::Request } assert result.all? { |obj| obj.instance_of? Docs::Request }

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsResponseTest < MiniTest::Spec class DocsResponseTest < MiniTest::Spec
let :response do let :response do

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsScraperTest < MiniTest::Spec class DocsScraperTest < MiniTest::Spec
class Scraper < Docs::Scraper class Scraper < Docs::Scraper
@ -223,7 +223,7 @@ class DocsScraperTest < MiniTest::Spec
context "when the response is processable" do context "when the response is processable" do
before 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) } urls.each { |url| @next_urls ||= block.call(response) }
end end
stub(scraper).handle_response(response) { processed_response } stub(scraper).handle_response(response) { processed_response }

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class FileScraperTest < MiniTest::Spec class FileScraperTest < MiniTest::Spec
ROOT_PATH = File.expand_path('../../../../../../', __FILE__) ROOT_PATH = File.expand_path('../../../../../../', __FILE__)

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class DocsUrlScraperTest < MiniTest::Spec class DocsUrlScraperTest < MiniTest::Spec
class Scraper < Docs::UrlScraper class Scraper < Docs::UrlScraper
@ -54,29 +54,29 @@ class DocsUrlScraperTest < MiniTest::Spec
end end
it "runs a Requester with the given urls" do 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 result
end end
it "runs a Requester with .headers as :request_options" do it "runs a Requester with .headers as :request_options" do
stub(Scraper).headers { { testheader: true } } 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 result
end end
it "runs a Requester with default .headers as :request_options" do 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 result
end end
it "runs a Requester with .params as :request_options" do it "runs a Requester with .params as :request_options" do
stub(Scraper).params { { test: true } } 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 result
end end
it "runs a Requester with the given block" do 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 result
assert_equal block, @block assert_equal block, @block
end end

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsUrlTest < MiniTest::Spec class DocsUrlTest < MiniTest::Spec
URL = Docs::URL URL = Docs::URL

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class ApplyBaseUrlFilterTest < MiniTest::Spec class ApplyBaseUrlFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class CleanHtmlFilterTest < MiniTest::Spec class CleanHtmlFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class CleanTextFilterTest < MiniTest::Spec class CleanTextFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class ContainerFilterTest < MiniTest::Spec class ContainerFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class EntriesFilterTest < MiniTest::Spec class EntriesFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class InnerHtmlFilterTest < MiniTest::Spec class InnerHtmlFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class InternalUrlsFilterTest < MiniTest::Spec class InternalUrlsFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class NormalizePathsFilterTest < MiniTest::Spec class NormalizePathsFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class NormalizeUrlsFilterTest < MiniTest::Spec class NormalizeUrlsFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class ParseCfEmailFilterTest < MiniTest::Spec class ParseCfEmailFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../../test_helper'
require 'docs' require_relative '../../../../../lib/docs'
class TitleFilterTest < MiniTest::Spec class TitleFilterTest < MiniTest::Spec
include FilterTestHelper include FilterTestHelper

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsAbstractStoreTest < MiniTest::Spec class DocsAbstractStoreTest < MiniTest::Spec
InvalidPathError = Docs::AbstractStore::InvalidPathError InvalidPathError = Docs::AbstractStore::InvalidPathError
@ -368,7 +368,7 @@ class DocsAbstractStoreTest < MiniTest::Spec
end end
def stub_paths(*paths) def stub_paths(*paths)
stub(store).each { |block| paths.each(&block) } stub(store).each { |&block| paths.each(&block) }
end end
it "calls the block" do it "calls the block" do

@ -1,5 +1,5 @@
require 'test_helper' require_relative '../../../test_helper'
require 'docs' require_relative '../../../../lib/docs'
class DocsFileStoreTest < MiniTest::Spec class DocsFileStoreTest < MiniTest::Spec
let :store do let :store do

Loading…
Cancel
Save