Unified · Split
| @@ -149,5 +149,29 @@ module Docs · 148 unmodified lines | ||
| 149 | 149 | def parse(string) |
| 150 | 150 | Parser.new(string).html |
| 151 | 151 | end |
| 152 | + | |
| 153 | + module StubRootPage | |
| 154 | + private | |
| 155 | + | |
| 156 | + def request_one(url) | |
| 157 | + stub_root_page if url == root_url.to_s | |
| 158 | + super | |
| 159 | + end | |
| 160 | + | |
| 161 | + def request_all(urls, &block) | |
| 162 | + stub_root_page | |
| 163 | + super | |
| 164 | + end | |
| 165 | + | |
| 166 | + def stub_root_page | |
| 167 | + response = Typhoeus::Response.new( | |
| 168 | + effective_url: root_url.to_s, | |
| 169 | + code: 200, | |
| 170 | + headers: { 'Content-Type' => 'text/html' }, | |
| 171 | + body: root_page_body) | |
| 172 | + | |
| 173 | + Typhoeus.stub(root_url.to_s).and_return(response) | |
| 174 | + end | |
| 175 | + end | |
| 152 | 176 | end |
| 153 | 177 | end |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Angular < UrlScraper |
| 3 | + include StubRootPage | |
| 4 | + | |
| 3 | 5 | self.name = 'Angular.js' |
| 4 | 6 | self.slug = 'angular' |
| 5 | 7 | self.type = 'angular' |
| @@ -28,27 +30,7 @@ module Docs · 22 unmodified lines | ||
| 28 | 30 | |
| 29 | 31 | private |
| 30 | 32 | |
| 31 | − def request_one(url) | |
| 32 | − stub_root_page if url == root_url.to_s | |
| 33 | − super | |
| 34 | − end | |
| 35 | − | |
| 36 | − def request_all(urls, &block) | |
| 37 | − stub_root_page | |
| 38 | − super | |
| 39 | − end | |
| 40 | − | |
| 41 | − def stub_root_page | |
| 42 | − response = Typhoeus::Response.new( | |
| 43 | − effective_url: root_url.to_s, | |
| 44 | − code: 200, | |
| 45 | − headers: { 'Content-Type' => 'text/html' }, | |
| 46 | − body: get_root_page_body) | |
| 47 | − | |
| 48 | − Typhoeus.stub(root_url.to_s).and_return(response) | |
| 49 | − end | |
| 50 | − | |
| 51 | − def get_root_page_body | |
| 33 | + def root_page_body | |
| 52 | 34 | require 'capybara' |
| 53 | 35 | Capybara.current_driver = :selenium |
| 54 | 36 | Capybara.visit("https://code.angularjs.org/#{self.class.version}/docs/api") |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Meteor < UrlScraper |
| 3 | + include StubRootPage | |
| 4 | + | |
| 3 | 5 | self.type = 'meteor' |
| 4 | 6 | self.version = '1.1.0' |
| 5 | 7 | self.base_url = 'http://docs.meteor.com' |
| @@ -21,27 +23,7 @@ module Docs · 15 unmodified lines | ||
| 21 | 23 | |
| 22 | 24 | private |
| 23 | 25 | |
| 24 | − def request_one(url) | |
| 25 | − stub_root_page if url == root_url.to_s | |
| 26 | − super | |
| 27 | − end | |
| 28 | − | |
| 29 | − def request_all(urls, &block) | |
| 30 | − stub_root_page | |
| 31 | − super | |
| 32 | − end | |
| 33 | − | |
| 34 | − def stub_root_page | |
| 35 | − response = Typhoeus::Response.new( | |
| 36 | − effective_url: root_url.to_s, | |
| 37 | − code: 200, | |
| 38 | − headers: { 'Content-Type' => 'text/html' }, | |
| 39 | − body: get_root_page_body) | |
| 40 | − | |
| 41 | − Typhoeus.stub(root_url.to_s).and_return(response) | |
| 42 | − end | |
| 43 | − | |
| 44 | − def get_root_page_body | |
| 26 | + def root_page_body | |
| 45 | 27 | require 'capybara' |
| 46 | 28 | Capybara.current_driver = :selenium |
| 47 | 29 | Capybara.visit(root_url.to_s) |