| @@ -3,8 +3,7 @@ require 'docs' · 2 unmodified lines |
| 3 | 3 | |
| 4 | 4 | class FileScraperTest < MiniTest::Spec |
| 5 | 5 | class Scraper < Docs::FileScraper |
| 6 | | − self.dir = '/dir' |
| 7 | | − self.base_url = 'http://example.com' |
| 6 | + self.dir = '/' |
| 8 | 7 | self.html_filters = Docs::FilterStack.new |
| 9 | 8 | self.text_filters = Docs::FilterStack.new |
| 10 | 9 | end |
| @@ -17,19 +16,30 @@ class FileScraperTest < MiniTest::Spec · 6 unmodified lines |
| 17 | 16 | OpenStruct.new body: 'body', url: Docs::URL.parse(Scraper.base_url) |
| 18 | 17 | end |
| 19 | 18 | |
| 19 | + describe ".inherited" do |
| 20 | + it "sets .base_url" do |
| 21 | + assert_equal Scraper.base_url, Class.new(Scraper).base_url |
| 22 | + end |
| 23 | + end |
| 24 | + |
| 20 | 25 | describe "#request_one" do |
| 21 | | − let :url do |
| 22 | | − File.join(Scraper.base_url, 'path') |
| 26 | + let :path do |
| 27 | + File.join(Scraper.dir, 'path') |
| 23 | 28 | end |
| 24 | 29 | |
| 25 | 30 | let :result do |
| 26 | | − scraper.send :request_one, url |
| 31 | + scraper.send :request_one, path |
| 27 | 32 | end |
| 28 | 33 | |
| 29 | 34 | before do |
| 30 | 35 | stub(scraper).read_file |
| 31 | 36 | end |
| 32 | 37 | |
| 38 | + it "reads a file" do |
| 39 | + mock(scraper).read_file(path) |
| 40 | + result |
| 41 | + end |
| 42 | + |
| 33 | 43 | describe "the returned response object" do |
| 34 | 44 | it "has a #body" do |
| 35 | 45 | stub(scraper).read_file { 'body' } |
| @@ -37,15 +47,10 @@ class FileScraperTest < MiniTest::Spec · 1 unmodified line |
| 37 | 47 | end |
| 38 | 48 | |
| 39 | 49 | it "has a #url" do |
| 40 | | − assert_equal url, result.url.to_s |
| 50 | + assert_equal path, result.url.to_s |
| 41 | 51 | assert_instance_of Docs::URL, result.url |
| 42 | 52 | end |
| 43 | 53 | end |
| 44 | | − |
| 45 | | − it "reads .dir/path when the url is .base_url/path" do |
| 46 | | − stub(scraper).read_file(File.join(Scraper.dir, 'path')) { 'test' } |
| 47 | | − assert_equal 'test', result.body |
| 48 | | − end |
| 49 | 54 | end |
| 50 | 55 | |
| 51 | 56 | describe "#request_all" do |