mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1024 from jmerle/fix-openjdk-read-file
Fix OpenJDK scraper
This commit is contained in:
commit
536003c54d
2 changed files with 4 additions and 4 deletions
|
@ -29,7 +29,7 @@ module Docs
|
||||||
|
|
||||||
def request_one(url)
|
def request_one(url)
|
||||||
assert_source_directory_exists
|
assert_source_directory_exists
|
||||||
Response.new read_file(url_to_path(url)), URL.parse(url)
|
Response.new read_file(File.join(source_directory, url_to_path(url))), URL.parse(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_all(urls)
|
def request_all(urls)
|
||||||
|
@ -50,7 +50,7 @@ module Docs
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_file(path)
|
def read_file(path)
|
||||||
File.read(File.join(source_directory, path))
|
File.read(path)
|
||||||
rescue
|
rescue
|
||||||
instrument 'warn.doc', msg: "Failed to open file: #{path}"
|
instrument 'warn.doc', msg: "Failed to open file: #{path}"
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FileScraperTest < MiniTest::Spec
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reads a file" do
|
it "reads a file" do
|
||||||
mock(scraper).read_file(path)
|
mock(scraper).read_file(File.join(ROOT_PATH, 'docs/scraper', path))
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ class FileScraperTest < MiniTest::Spec
|
||||||
|
|
||||||
describe "#read_file" do
|
describe "#read_file" do
|
||||||
let :result do
|
let :result do
|
||||||
scraper.send :read_file, 'file'
|
scraper.send :read_file, File.join(ROOT_PATH, 'docs', 'scraper', 'file')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the file's content when the file exists in the source directory" do
|
it "returns the file's content when the file exists in the source directory" do
|
||||||
|
|
Loading…
Reference in a new issue