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'
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'

@ -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

@ -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)

@ -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

@ -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

@ -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

@ -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),

@ -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

@ -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

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

@ -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

@ -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

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

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

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

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

@ -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

@ -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 }

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

@ -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 }

@ -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__)

@ -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

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

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

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

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

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

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

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

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

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

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

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

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

@ -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

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

Loading…
Cancel
Save