Skip to content

Commit 05e73e3

Browse files
committed
Adds InvalidProfileError to MatchHistoryScraper
1 parent 06037ba commit 05e73e3

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/bnet_scraper/starcraft2/match_history_scraper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def get_response
2929

3030
if @response.success?
3131
@response = Nokogiri::HTML(@response.body)
32+
else
33+
raise BnetScraper::InvalidProfileError
3234
end
3335
end
3436

spec/starcraft2/match_history_scraper_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
it 'should set the match date of each match' do
3535
subject.matches[0][:date].should == '3/12/2012'
3636
end
37+
38+
it 'should raised InvalidProfileError when response is 404' do
39+
url = 'http://us.battle.net/sc2/en/profile/2377239/1/SomeDude/matches'
40+
scraper = BnetScraper::Starcraft2::MatchHistoryScraper.new(url: url)
41+
expect { scraper.scrape }.to raise_error(BnetScraper::InvalidProfileError)
42+
end
3743
end
3844

3945
describe '#output' do

spec/support/load_fakeweb.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/SomeDude/', body: failure_html, status: 404, content_type: 'text/html'
1313
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/SomeDude/achievements/', body: failure_html, status: 404, content_type: 'text/html'
1414
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/SomeDude/leagues/12345', body: failure_html, status: 404, content_type: 'text/html'
15+
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/SomeDude/matches', body: failure_html, status: 404, content_type: 'text/html'
1516
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/Demon/', body: profile_html, status: 200, content_type: 'text/html'
1617
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/Demon/ladder/leagues', body: leagues_html, status: 200, content_type: 'text/html'
1718
FakeWeb.register_uri :get, 'http://us.battle.net/sc2/en/profile/2377239/1/Demon/ladder/12345', body: league_html, status: 200, content_type: 'text/html'

0 commit comments

Comments
 (0)