|
4 | 4 | let(:url) { 'http://us.battle.net/sc2/en/profile/2377239/1/Demon/achievements/' } |
5 | 5 | subject { BnetScraper::Starcraft2::AchievementScraper.new(url: url) } |
6 | 6 |
|
7 | | - describe '#initialize' do |
8 | | - context 'with url parameter passed' do |
9 | | - it 'should extract bnet_id from the URL' do |
10 | | - subject.bnet_id.should == '2377239' |
11 | | - end |
12 | | - |
13 | | - it 'should extract account from the URL' do |
14 | | - subject.account.should == 'Demon' |
15 | | - end |
16 | | - |
17 | | - it 'should extract the bnet_index from the URL' do |
18 | | - subject.bnet_index.should == '1' |
19 | | - end |
20 | | - |
21 | | - it 'should extract the region from the URL' do |
22 | | - subject.region.should == 'na' |
23 | | - end |
24 | | - end |
25 | | - |
26 | | - context 'when bnet_id and account parameters are passed' do |
27 | | - subject { BnetScraper::Starcraft2::AchievementScraper.new(bnet_id: '2377239', account: 'Demon') } |
28 | | - it 'should set the bnet_id and account parameters' do |
29 | | - subject.bnet_id.should == '2377239' |
30 | | - subject.account.should == 'Demon' |
31 | | - end |
32 | | - |
33 | | - it 'should default the region to na' do |
34 | | - subject.region.should == 'na' |
35 | | - end |
36 | | - |
37 | | - it 'should assign region if passed' do |
38 | | - BnetScraper::Starcraft2::AchievementScraper.any_instance.should_receive(:set_bnet_index) |
39 | | - scraper = BnetScraper::Starcraft2::AchievementScraper.new(bnet_id: '2377239', account: 'Demon', region: 'fea') |
40 | | - scraper.region.should == 'fea' |
41 | | - end |
42 | | - |
43 | | - it 'should not call set_bnet_index if bnet_index is passed' do |
44 | | - BnetScraper::Starcraft2::AchievementScraper.any_instance.should_not_receive(:set_bnet_index) |
45 | | - scraper = BnetScraper::Starcraft2::AchievementScraper.new(bnet_id: '2377239', account: 'Demon', region: 'fea', bnet_index: '1') |
46 | | - end |
47 | | - |
48 | | - it 'should call set_bnet_index_if bnet_index is not passed' do |
49 | | - BnetScraper::Starcraft2::AchievementScraper.any_instance.should_receive(:set_bnet_index) |
50 | | - scraper = BnetScraper::Starcraft2::AchievementScraper.new(bnet_id: '2377239', account: 'Demon', region: 'fea') |
51 | | - end |
52 | | - end |
| 7 | + it_behaves_like 'an SC2 Scraper' do |
| 8 | + let(:scraper_class) { BnetScraper::Starcraft2::AchievementScraper } |
| 9 | + let(:subject) { scraper_class.new(url: url) } |
53 | 10 | end |
54 | 11 |
|
55 | 12 | describe '#get_response' do |
|
0 commit comments