thetvdb_mapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/lib/thetvdb_mapper/actors.rb +13 -0
- data/lib/thetvdb_mapper/banners.rb +13 -0
- data/lib/thetvdb_mapper/base.rb +11 -0
- data/lib/thetvdb_mapper/episode.rb +9 -0
- data/lib/thetvdb_mapper/fetcher.rb +25 -0
- data/lib/thetvdb_mapper/full_series.rb +37 -0
- data/lib/thetvdb_mapper/mapping/actor.rb +11 -0
- data/lib/thetvdb_mapper/mapping/banner.rb +17 -0
- data/lib/thetvdb_mapper/mapping/base.rb +17 -0
- data/lib/thetvdb_mapper/mapping/episode.rb +45 -0
- data/lib/thetvdb_mapper/mapping/series.rb +36 -0
- data/lib/thetvdb_mapper/mapping/string_list.rb +5 -0
- data/lib/thetvdb_mapper/series.rb +9 -0
- data/lib/thetvdb_mapper/version.rb +3 -0
- data/lib/thetvdb_mapper.rb +18 -0
- data/spec/functionals/mapping/actor_spec.rb +31 -0
- data/spec/functionals/mapping/banner_spec.rb +56 -0
- data/spec/functionals/mapping/episode_spec.rb +135 -0
- data/spec/functionals/mapping/series_spec.rb +105 -0
- data/spec/integrations/classes/actors_spec.rb +11 -0
- data/spec/integrations/classes/banners_spec.rb +11 -0
- data/spec/integrations/classes/episode_spec.rb +11 -0
- data/spec/integrations/classes/fetcher_spec.rb +35 -0
- data/spec/integrations/classes/full_series_spec.rb +11 -0
- data/spec/integrations/classes/series_spec.rb +11 -0
- data/spec/integrations/integration_spec_helper.rb +2 -0
- data/spec/integrations/support/.keep +0 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/units/actors_spec.rb +33 -0
- data/spec/units/banners_spec.rb +33 -0
- data/spec/units/base_spec.rb +15 -0
- data/spec/units/episode_spec.rb +26 -0
- data/spec/units/fetcher_spec.rb +67 -0
- data/spec/units/full_series_spec.rb +109 -0
- data/spec/units/mapping/actor_spec.rb +27 -0
- data/spec/units/mapping/banner_spec.rb +51 -0
- data/spec/units/mapping/base_spec.rb +29 -0
- data/spec/units/mapping/episode_spec.rb +141 -0
- data/spec/units/mapping/series_spec.rb +113 -0
- data/spec/units/mapping/string_list_spec.rb +11 -0
- data/spec/units/series_spec.rb +26 -0
- data/thetvdb_mapper.gemspec +27 -0
- metadata +188 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Mapping::Series do
|
4
|
+
let(:klass) { ThetvdbMapper::Mapping::Series }
|
5
|
+
|
6
|
+
describe '#map' do
|
7
|
+
it 'should return specific keys' do
|
8
|
+
klass.map({}).keys.sort.should == [:id, :airs_day_of_week, :airs_time, :content_rating, :first_aired, :genres,
|
9
|
+
:imdb_id, :language, :network, :network_id, :overview, :rating, :rating_count, :runtime, :name, :status,
|
10
|
+
:added_at, :added_by, :banner_path, :fanart_path, :last_updated_at, :poster_path, :zap2it_id].sort
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should map id' do
|
14
|
+
klass.map('id' => 1234)[:id].should == 1234
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should map Airs_DayOfWeek' do
|
18
|
+
klass.map('Airs_DayOfWeek' => 'Monday')[:airs_day_of_week].should == 'Monday'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should map Airs_Time' do
|
22
|
+
klass.map('Airs_Time' => '8:00 AM')[:airs_time].should == '8:00 AM'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should map ContentRating' do
|
26
|
+
klass.map('ContentRating' => 'TV-PG')[:content_rating].should == 'TV-PG'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should map FirstAired' do
|
30
|
+
klass.map('FirstAired' => '1997-07-01')[:first_aired].should == '1997-07-01'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should map genre' do
|
34
|
+
klass.map('genre' => '|comedy|')[:genres].should == ['comedy']
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should map IMDB_ID' do
|
38
|
+
klass.map('IMDB_ID' => 'tt0118480')[:imdb_id].should == 'tt0118480'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should map Language' do
|
42
|
+
klass.map('Language' => 'en')[:language].should == 'en'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should map Network' do
|
46
|
+
klass.map('Network' => 'SciFi')[:network].should == 'SciFi'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should map NetworkID' do
|
50
|
+
klass.map('NetworkID' => '1')[:network_id].should == '1'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should map Overview' do
|
54
|
+
klass.map('Overview' => 'example overview')[:overview].should == 'example overview'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should map Rating' do
|
58
|
+
klass.map('Rating' => '1.0')[:rating].should == '1.0'
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should map RatingCount' do
|
62
|
+
klass.map('RatingCount' => '1')[:rating_count].should == '1'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should map Runtime' do
|
66
|
+
klass.map('Runtime' => '45')[:runtime].should == '45'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should map SeriesName' do
|
70
|
+
klass.map('SeriesName' => 'Stargate SG-1')[:name].should == 'Stargate SG-1'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should map Status' do
|
74
|
+
klass.map('Status' => 'Ended')[:status].should == 'Ended'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should map added' do
|
78
|
+
klass.map('added' => '1')[:added_at].should == '1'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should map added_by' do
|
82
|
+
klass.map('added_by' => '1')[:added_by].should == '1'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should map banner' do
|
86
|
+
klass.map('banner' => 'PATH')[:banner_path].should == 'PATH'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should map fanart' do
|
90
|
+
klass.map('fanart' => 'PATH')[:fanart_path].should == 'PATH'
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should map lastupdated' do
|
94
|
+
klass.map('lastupdated' => '1234')[:last_updated_at].should == Time.at(1234)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should map poster' do
|
98
|
+
klass.map('poster' => 'PATH')[:poster_path].should == 'PATH'
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should map zap2it_id' do
|
102
|
+
klass.map('zap2it_id' => '1234')[:zap2it_id].should == '1234'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'integrations/integration_spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Fetcher do
|
4
|
+
let(:model) { ThetvdbMapper::Fetcher.new }
|
5
|
+
|
6
|
+
describe '.series' do
|
7
|
+
it 'should return hash' do
|
8
|
+
model.series(80348).body.class.should == Hash
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.full_series' do
|
13
|
+
it 'should return hash' do
|
14
|
+
model.full_series(80348).body.class.should == Hash
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.actors' do
|
19
|
+
it 'should return array' do
|
20
|
+
model.actors(80348).body.class.should == Array
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.banners' do
|
25
|
+
it 'should return array' do
|
26
|
+
model.banners(80348).body.class.should == Array
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.episode' do
|
31
|
+
it 'should return hash' do
|
32
|
+
model.episode(332179).body.class.should == Hash
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Actors do
|
4
|
+
let(:model) { ThetvdbMapper::Actors.new(1) }
|
5
|
+
|
6
|
+
describe '.data' do
|
7
|
+
before do
|
8
|
+
model.stub_chain(:fetcher, :actors, :body).and_return([{}])
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should call map' do
|
12
|
+
model.should_receive(:map)
|
13
|
+
model.data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.map' do
|
18
|
+
it 'should call map on mapping class' do
|
19
|
+
ThetvdbMapper::Mapping::Actor.should_receive(:map).with(sample: true)
|
20
|
+
model.map(sample: true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.inspect' do
|
25
|
+
before do
|
26
|
+
model.stub(:data).and_return('DATA')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return correct string' do
|
30
|
+
model.inspect.should == '<ThetvdbMapper::Actors data=DATA >'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Banners do
|
4
|
+
let(:model) { ThetvdbMapper::Banners.new(1) }
|
5
|
+
|
6
|
+
describe '.data' do
|
7
|
+
before do
|
8
|
+
model.stub_chain(:fetcher, :banners, :body).and_return([{}])
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should call map' do
|
12
|
+
model.should_receive(:map)
|
13
|
+
model.data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.map' do
|
18
|
+
it 'should call map on mapping class' do
|
19
|
+
ThetvdbMapper::Mapping::Banner.should_receive(:map).with(sample: true)
|
20
|
+
model.map(sample: true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.inspect' do
|
25
|
+
before do
|
26
|
+
model.stub(:data).and_return('DATA')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return correct string' do
|
30
|
+
model.inspect.should == '<ThetvdbMapper::Banners data=DATA >'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ExampleClass < ThetvdbMapper::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
describe ThetvdbMapper::Base do
|
7
|
+
let(:model) { ExampleClass.new(1) }
|
8
|
+
|
9
|
+
describe '.fetcher' do
|
10
|
+
it 'should call map' do
|
11
|
+
ThetvdbMapper::Fetcher.should_receive(:new)
|
12
|
+
model.fetcher
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Episode do
|
4
|
+
let(:model) { ThetvdbMapper::Episode.new(1) }
|
5
|
+
|
6
|
+
describe '.data' do
|
7
|
+
before do
|
8
|
+
model.stub_chain(:fetcher, :episode, :body).and_return(sample: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should call map on mapping class' do
|
12
|
+
ThetvdbMapper::Mapping::Episode.should_receive(:map).with(sample: true)
|
13
|
+
model.data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.inspect' do
|
18
|
+
before do
|
19
|
+
model.stub(:data).and_return('DATA')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return correct string' do
|
23
|
+
model.inspect.should == '<ThetvdbMapper::Episode data=DATA >'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Fetcher do
|
4
|
+
let(:model) { ThetvdbMapper::Fetcher.new }
|
5
|
+
|
6
|
+
describe '.series' do
|
7
|
+
before do
|
8
|
+
model.stub_chain(:client, :series).and_return(double(find: true))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should call series find' do
|
12
|
+
model.client.series.should_receive(:find).with(1, mapping: true)
|
13
|
+
model.series(1)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.full_series' do
|
18
|
+
before do
|
19
|
+
model.stub_chain(:client, :series).and_return(double(find_full: true))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should call series find_full' do
|
23
|
+
model.client.series.should_receive(:find_full).with(1, mapping: true)
|
24
|
+
model.full_series(1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.actors' do
|
29
|
+
before do
|
30
|
+
model.stub_chain(:client, :actor).and_return(double(find: true))
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should call actor all' do
|
34
|
+
model.client.actor.should_receive(:find).with(1, mapping: true)
|
35
|
+
model.actors(1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.banners' do
|
40
|
+
before do
|
41
|
+
model.stub_chain(:client, :banner).and_return(double(find: true))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should call banner all' do
|
45
|
+
model.client.banner.should_receive(:find).with(1, mapping: true)
|
46
|
+
model.banners(1)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.episode' do
|
51
|
+
before do
|
52
|
+
model.stub_chain(:client, :episode).and_return(double(find: true))
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should call episode find_by_default_order' do
|
56
|
+
model.client.episode.should_receive(:find).with(1, mapping: true)
|
57
|
+
model.episode(1)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '.client' do
|
62
|
+
it 'should create ThetvdbApi::Client instance' do
|
63
|
+
ThetvdbApi::Client.should_receive(:new)
|
64
|
+
model.client
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::FullSeries do
|
4
|
+
let(:model) { ThetvdbMapper::FullSeries.new(1) }
|
5
|
+
|
6
|
+
describe '.data' do
|
7
|
+
before do
|
8
|
+
model.stub(:series).and_return({})
|
9
|
+
model.stub(:episodes).and_return([])
|
10
|
+
model.stub(:actors).and_return([])
|
11
|
+
model.stub(:banners).and_return([])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should call series' do
|
15
|
+
model.stub(:series).and_return(sample: true)
|
16
|
+
model.data[:sample].should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should store episodes in data hash' do
|
20
|
+
model.stub(:episodes).and_return([{ sample: true }])
|
21
|
+
model.data[:episodes].should == [{ sample: true }]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should store actors in data hash' do
|
25
|
+
model.stub(:actors).and_return([{ sample: true }])
|
26
|
+
model.data[:actors].should == [{ sample: true }]
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should store banners in data hash' do
|
30
|
+
model.stub(:banners).and_return([{ sample: true }])
|
31
|
+
model.data[:banners].should == [{ sample: true }]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.series' do
|
36
|
+
before do
|
37
|
+
model.stub_chain(:fetcher, :full_series, :body).and_return({ 'Series' => { sample: true } })
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should map series' do
|
41
|
+
ThetvdbMapper::Mapping::Series.should_receive(:map).with(sample: true)
|
42
|
+
model.series
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.episodes' do
|
47
|
+
before do
|
48
|
+
model.stub_chain(:fetcher, :full_series, :body).and_return({ 'Episode' => [{ sample: true }] })
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should map episode' do
|
52
|
+
model.should_receive(:map_episode).with(sample: true)
|
53
|
+
model.episodes
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.map_episode' do
|
58
|
+
it 'should map episode' do
|
59
|
+
ThetvdbMapper::Mapping::Episode.should_receive(:map).with(sample: true)
|
60
|
+
model.map_episode(sample: true)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.actors' do
|
65
|
+
before do
|
66
|
+
model.stub_chain(:fetcher, :actors, :body).and_return([{ sample: true }])
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should map actor' do
|
70
|
+
model.should_receive(:map_actor).with(sample: true)
|
71
|
+
model.actors
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.map_actor' do
|
76
|
+
it 'should map actor' do
|
77
|
+
ThetvdbMapper::Mapping::Actor.should_receive(:map).with(sample: true)
|
78
|
+
model.map_actor(sample: true)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '.banners' do
|
83
|
+
before do
|
84
|
+
model.stub_chain(:fetcher, :banners, :body).and_return([{ sample: true }])
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should map banner' do
|
88
|
+
model.should_receive(:map_banner).with(sample: true)
|
89
|
+
model.banners
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '.map_banner' do
|
94
|
+
it 'should map banner' do
|
95
|
+
ThetvdbMapper::Mapping::Banner.should_receive(:map).with(sample: true)
|
96
|
+
model.map_banner(sample: true)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.inspect' do
|
101
|
+
before do
|
102
|
+
model.stub(:data).and_return('DATA')
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should return correct string' do
|
106
|
+
model.inspect.should == '<ThetvdbMapper::FullSeries data=DATA >'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Mapping::Actor do
|
4
|
+
let(:klass) { ThetvdbMapper::Mapping::Actor }
|
5
|
+
|
6
|
+
describe '#rules' do
|
7
|
+
it 'should map id' do
|
8
|
+
klass.rules['id'].should == :id
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should map Image' do
|
12
|
+
klass.rules['Image'].should == :image_path
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should map Name' do
|
16
|
+
klass.rules['Name'].should == :name
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should map Role' do
|
20
|
+
klass.rules['Role'].should == :role
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should map SortOrder' do
|
24
|
+
klass.rules['SortOrder'].should == :sort_order
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ThetvdbMapper::Mapping::Banner do
|
4
|
+
let(:klass) { ThetvdbMapper::Mapping::Banner }
|
5
|
+
|
6
|
+
describe '#rules' do
|
7
|
+
it 'should map BannerPath' do
|
8
|
+
klass.rules['BannerPath'].should == :path
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should map ThumbnailPath' do
|
12
|
+
klass.rules['ThumbnailPath'].should == :thumbnail_path
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should map VignettePath' do
|
16
|
+
klass.rules['VignettePath'].should == :vignette_path
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should map BannerType' do
|
20
|
+
klass.rules['BannerType'].should == :type
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should map BannerType2' do
|
24
|
+
klass.rules['BannerType2'].should == :type2
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should map Language' do
|
28
|
+
klass.rules['Language'].should == :language
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should map Season' do
|
32
|
+
klass.rules['Season'].should == :season
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should map Rating' do
|
36
|
+
klass.rules['Rating'].should == :rating
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should map RatingCount' do
|
40
|
+
klass.rules['RatingCount'].should == :rating_count
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should map SeriesName' do
|
44
|
+
klass.rules['SeriesName'].should == :series_name
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should map Colors' do
|
48
|
+
klass.rules['Colors'].should == :colors
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class MappingExample < ThetvdbMapper::Mapping::Base
|
2
|
+
end
|
3
|
+
|
4
|
+
describe ThetvdbMapper::Mapping::Banner do
|
5
|
+
let(:klass) { MappingExample }
|
6
|
+
|
7
|
+
describe '#map' do
|
8
|
+
before do
|
9
|
+
klass.stub(:rules).and_return(sample: :example)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should convert hash' do
|
13
|
+
klass.map(sample: 'test').should == { example: 'test' }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should call convert method if exists' do
|
17
|
+
klass.stub(:respond_to?).with(:convert).and_return(true)
|
18
|
+
klass.should_receive(:convert)
|
19
|
+
klass.map(sample: 'test')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#convert_to_list' do
|
24
|
+
it 'should return correct hash' do
|
25
|
+
ThetvdbMapper::Mapping::StringList.should_receive(:map).with('test')
|
26
|
+
klass.convert_to_list('test')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|