thetvdb_mapper 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,105 +1,128 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ThetvdbMapper::Mapping::Series do
4
- let(:klass) { ThetvdbMapper::Mapping::Series }
4
+ let(:model) { ThetvdbMapper::Mapping::Series.new({}) }
5
5
 
6
6
  describe '#map' do
7
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,
8
+ model.map.keys.sort.should == [:id, :airs_day_of_week, :airs_time, :content_rating, :first_aired, :genres,
9
9
  :imdb_id, :language, :network, :network_id, :overview, :rating, :rating_count, :runtime, :name, :status,
10
10
  :added_at, :added_by, :banner_path, :fanart_path, :last_updated_at, :poster_path, :zap2it_id].sort
11
11
  end
12
12
 
13
13
  it 'should map id' do
14
- klass.map('id' => 1234)[:id].should == 1234
14
+ model.stub(:data).and_return('id' => 1234)
15
+ model.map[:id].should == 1234
15
16
  end
16
17
 
17
18
  it 'should map Airs_DayOfWeek' do
18
- klass.map('Airs_DayOfWeek' => 'Monday')[:airs_day_of_week].should == 'Monday'
19
+ model.stub(:data).and_return('Airs_DayOfWeek' => 'Monday')
20
+ model.map[:airs_day_of_week].should == 'Monday'
19
21
  end
20
22
 
21
23
  it 'should map Airs_Time' do
22
- klass.map('Airs_Time' => '8:00 AM')[:airs_time].should == '8:00 AM'
24
+ model.stub(:data).and_return('Airs_Time' => '8:00 AM')
25
+ model.map[:airs_time].should == '8:00 AM'
23
26
  end
24
27
 
25
28
  it 'should map ContentRating' do
26
- klass.map('ContentRating' => 'TV-PG')[:content_rating].should == 'TV-PG'
29
+ model.stub(:data).and_return('ContentRating' => 'TV-PG')
30
+ model.map[:content_rating].should == 'TV-PG'
27
31
  end
28
32
 
29
33
  it 'should map FirstAired' do
30
- klass.map('FirstAired' => '1997-07-01')[:first_aired].should == '1997-07-01'
34
+ model.stub(:data).and_return('FirstAired' => '1997-07-01')
35
+ model.map[:first_aired].should == '1997-07-01'
31
36
  end
32
37
 
33
38
  it 'should map Genre' do
34
- klass.map('Genre' => '|comedy|')[:genres].should == ['comedy']
39
+ model.stub(:data).and_return('Genre' => '|comedy|')
40
+ model.map[:genres].should == ['comedy']
35
41
  end
36
42
 
37
43
  it 'should map IMDB_ID' do
38
- klass.map('IMDB_ID' => 'tt0118480')[:imdb_id].should == 'tt0118480'
44
+ model.stub(:data).and_return('IMDB_ID' => 'tt0118480')
45
+ model.map[:imdb_id].should == 'tt0118480'
39
46
  end
40
47
 
41
48
  it 'should map Language' do
42
- klass.map('Language' => 'en')[:language].should == 'en'
49
+ model.stub(:data).and_return('Language' => 'en')
50
+ model.map[:language].should == 'en'
43
51
  end
44
52
 
45
53
  it 'should map Network' do
46
- klass.map('Network' => 'SciFi')[:network].should == 'SciFi'
54
+ model.stub(:data).and_return('Network' => 'SciFi')
55
+ model.map[:network].should == 'SciFi'
47
56
  end
48
57
 
49
58
  it 'should map NetworkID' do
50
- klass.map('NetworkID' => '1')[:network_id].should == '1'
59
+ model.stub(:data).and_return('NetworkID' => '1')
60
+ model.map[:network_id].should == '1'
51
61
  end
52
62
 
53
63
  it 'should map Overview' do
54
- klass.map('Overview' => 'example overview')[:overview].should == 'example overview'
64
+ model.stub(:data).and_return('Overview' => 'example overview')
65
+ model.map[:overview].should == 'example overview'
55
66
  end
56
67
 
57
68
  it 'should map Rating' do
58
- klass.map('Rating' => '1.0')[:rating].should == '1.0'
69
+ model.stub(:data).and_return('Rating' => '1.0')
70
+ model.map[:rating].should == '1.0'
59
71
  end
60
72
 
61
73
  it 'should map RatingCount' do
62
- klass.map('RatingCount' => '1')[:rating_count].should == '1'
74
+ model.stub(:data).and_return('RatingCount' => '1')
75
+ model.map[:rating_count].should == '1'
63
76
  end
64
77
 
65
78
  it 'should map Runtime' do
66
- klass.map('Runtime' => '45')[:runtime].should == '45'
79
+ model.stub(:data).and_return('Runtime' => '45')
80
+ model.map[:runtime].should == '45'
67
81
  end
68
82
 
69
83
  it 'should map SeriesName' do
70
- klass.map('SeriesName' => 'Stargate SG-1')[:name].should == 'Stargate SG-1'
84
+ model.stub(:data).and_return('SeriesName' => 'Stargate SG-1')
85
+ model.map[:name].should == 'Stargate SG-1'
71
86
  end
72
87
 
73
88
  it 'should map Status' do
74
- klass.map('Status' => 'Ended')[:status].should == 'Ended'
89
+ model.stub(:data).and_return('Status' => 'Ended')
90
+ model.map[:status].should == 'Ended'
75
91
  end
76
92
 
77
93
  it 'should map added' do
78
- klass.map('added' => '1')[:added_at].should == '1'
94
+ model.stub(:data).and_return('added' => '1')
95
+ model.map[:added_at].should == '1'
79
96
  end
80
97
 
81
98
  it 'should map addedBy' do
82
- klass.map('addedBy' => '1')[:added_by].should == '1'
99
+ model.stub(:data).and_return('addedBy' => '1')
100
+ model.map[:added_by].should == '1'
83
101
  end
84
102
 
85
103
  it 'should map banner' do
86
- klass.map('banner' => 'PATH')[:banner_path].should == 'PATH'
104
+ model.stub(:data).and_return('banner' => 'PATH')
105
+ model.map[:banner_path].should == 'PATH'
87
106
  end
88
107
 
89
108
  it 'should map fanart' do
90
- klass.map('fanart' => 'PATH')[:fanart_path].should == 'PATH'
109
+ model.stub(:data).and_return('fanart' => 'PATH')
110
+ model.map[:fanart_path].should == 'PATH'
91
111
  end
92
112
 
93
113
  it 'should map lastupdated' do
94
- klass.map('lastupdated' => '1234')[:last_updated_at].should == Time.at(1234)
114
+ model.stub(:data).and_return('lastupdated' => '1234')
115
+ model.map[:last_updated_at].should == Time.at(1234)
95
116
  end
96
117
 
97
118
  it 'should map poster' do
98
- klass.map('poster' => 'PATH')[:poster_path].should == 'PATH'
119
+ model.stub(:data).and_return('poster' => 'PATH')
120
+ model.map[:poster_path].should == 'PATH'
99
121
  end
100
122
 
101
123
  it 'should map zap2it_id' do
102
- klass.map('zap2it_id' => '1234')[:zap2it_id].should == '1234'
124
+ model.stub(:data).and_return('zap2it_id' => '1234')
125
+ model.map[:zap2it_id].should == '1234'
103
126
  end
104
127
  end
105
128
  end
@@ -5,7 +5,6 @@ describe ThetvdbMapper::Episode do
5
5
 
6
6
  describe '.data' do
7
7
  it 'should return array' do
8
- puts model.data.inspect
9
8
  model.data.class.should == Hash
10
9
  end
11
10
  end
@@ -16,7 +16,8 @@ describe ThetvdbMapper::Actors do
16
16
 
17
17
  describe '.map' do
18
18
  it 'should call map on mapping class' do
19
- ThetvdbMapper::Mapping::Actor.should_receive(:map).with(sample: true)
19
+ model.stub(:mapping_object).with(sample: true).and_return(double(map: true))
20
+ model.mapping_object(sample: true).should_receive(:map)
20
21
  model.map(sample: true)
21
22
  end
22
23
  end
@@ -30,4 +31,10 @@ describe ThetvdbMapper::Actors do
30
31
  model.inspect.should == '<ThetvdbMapper::Actors data=DATA >'
31
32
  end
32
33
  end
34
+
35
+ describe '.mapping_object' do
36
+ it 'should return mapping actor instance' do
37
+ model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Actor
38
+ end
39
+ end
33
40
  end
@@ -16,7 +16,8 @@ describe ThetvdbMapper::Banners do
16
16
 
17
17
  describe '.map' do
18
18
  it 'should call map on mapping class' do
19
- ThetvdbMapper::Mapping::Banner.should_receive(:map).with(sample: true)
19
+ model.stub(:mapping_object).with(sample: true).and_return(double(map: true))
20
+ model.mapping_object(sample: true).should_receive(:map)
20
21
  model.map(sample: true)
21
22
  end
22
23
  end
@@ -30,4 +31,10 @@ describe ThetvdbMapper::Banners do
30
31
  model.inspect.should == '<ThetvdbMapper::Banners data=DATA >'
31
32
  end
32
33
  end
34
+
35
+ describe '.mapping_object' do
36
+ it 'should return mapping banner instance' do
37
+ model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Banner
38
+ end
39
+ end
33
40
  end
@@ -9,7 +9,8 @@ describe ThetvdbMapper::Episode do
9
9
  end
10
10
 
11
11
  it 'should call map on mapping class' do
12
- ThetvdbMapper::Mapping::Episode.should_receive(:map).with(sample: true)
12
+ model.stub(:mapping_object).and_return(double(map: true))
13
+ model.mapping_object(sample: true).should_receive(:map)
13
14
  model.data
14
15
  end
15
16
  end
@@ -23,4 +24,10 @@ describe ThetvdbMapper::Episode do
23
24
  model.inspect.should == '<ThetvdbMapper::Episode data=DATA >'
24
25
  end
25
26
  end
27
+
28
+ describe '.mapping_object' do
29
+ it 'should return mapping episode instance' do
30
+ model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Episode
31
+ end
32
+ end
26
33
  end
@@ -38,7 +38,8 @@ describe ThetvdbMapper::FullSeries do
38
38
  end
39
39
 
40
40
  it 'should map series' do
41
- ThetvdbMapper::Mapping::Series.should_receive(:map).with(sample: true)
41
+ model.stub(:mapping_series_object).and_return(double(map: true))
42
+ model.mapping_series_object(sample: true).should_receive(:map)
42
43
  model.series
43
44
  end
44
45
  end
@@ -56,7 +57,8 @@ describe ThetvdbMapper::FullSeries do
56
57
 
57
58
  describe '.map_episode' do
58
59
  it 'should map episode' do
59
- ThetvdbMapper::Mapping::Episode.should_receive(:map).with(sample: true)
60
+ model.stub(:mapping_episode_object).and_return(double(map: true))
61
+ model.mapping_episode_object(sample: true).should_receive(:map)
60
62
  model.map_episode(sample: true)
61
63
  end
62
64
  end
@@ -74,7 +76,8 @@ describe ThetvdbMapper::FullSeries do
74
76
 
75
77
  describe '.map_actor' do
76
78
  it 'should map actor' do
77
- ThetvdbMapper::Mapping::Actor.should_receive(:map).with(sample: true)
79
+ model.stub(:mapping_actor_object).and_return(double(map: true))
80
+ model.mapping_actor_object(sample: true).should_receive(:map)
78
81
  model.map_actor(sample: true)
79
82
  end
80
83
  end
@@ -91,12 +94,40 @@ describe ThetvdbMapper::FullSeries do
91
94
  end
92
95
 
93
96
  describe '.map_banner' do
97
+ before do
98
+ model.stub(:mapping_banner_object).with(sample: true).and_return(double(map: true))
99
+ end
100
+
94
101
  it 'should map banner' do
95
- ThetvdbMapper::Mapping::Banner.should_receive(:map).with(sample: true)
102
+ model.mapping_banner_object(sample: true).should_receive(:map)
96
103
  model.map_banner(sample: true)
97
104
  end
98
105
  end
99
106
 
107
+ describe '.mapping_series_object' do
108
+ it 'should return mapping series instance' do
109
+ model.mapping_series_object(sample: true).class.should == ThetvdbMapper::Mapping::Series
110
+ end
111
+ end
112
+
113
+ describe '.mapping_episode_object' do
114
+ it 'should return mapping episode instance' do
115
+ model.mapping_episode_object(sample: true).class.should == ThetvdbMapper::Mapping::Episode
116
+ end
117
+ end
118
+
119
+ describe '.mapping_actor_object' do
120
+ it 'should return mapping actor instance' do
121
+ model.mapping_actor_object(sample: true).class.should == ThetvdbMapper::Mapping::Actor
122
+ end
123
+ end
124
+
125
+ describe '.mapping_banner_object' do
126
+ it 'should return mapping banner instance' do
127
+ model.mapping_banner_object(sample: true).class.should == ThetvdbMapper::Mapping::Banner
128
+ end
129
+ end
130
+
100
131
  describe '.inspect' do
101
132
  before do
102
133
  model.stub(:data).and_return('DATA')
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ThetvdbMapper::Mapping::Actor do
4
- let(:klass) { ThetvdbMapper::Mapping::Actor }
4
+ let(:model) { ThetvdbMapper::Mapping::Actor.new({}) }
5
5
 
6
6
  describe '#rules' do
7
7
  it 'should map id' do
8
- klass.rules['id'].should == :id
8
+ model.rules['id'].should == :id
9
9
  end
10
10
 
11
11
  it 'should map Image' do
12
- klass.rules['Image'].should == :image_path
12
+ model.rules['Image'].should == :image_path
13
13
  end
14
14
 
15
15
  it 'should map Name' do
16
- klass.rules['Name'].should == :name
16
+ model.rules['Name'].should == :name
17
17
  end
18
18
 
19
19
  it 'should map Role' do
20
- klass.rules['Role'].should == :role
20
+ model.rules['Role'].should == :role
21
21
  end
22
22
 
23
23
  it 'should map SortOrder' do
24
- klass.rules['SortOrder'].should == :sort_order
24
+ model.rules['SortOrder'].should == :sort_order
25
25
  end
26
26
  end
27
27
  end
@@ -1,54 +1,54 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ThetvdbMapper::Mapping::Banner do
4
- let(:klass) { ThetvdbMapper::Mapping::Banner }
4
+ let(:model) { ThetvdbMapper::Mapping::Banner.new({}) }
5
5
 
6
6
  describe '#rules' do
7
7
  it 'should map id' do
8
- klass.rules['id'].should == :id
8
+ model.rules['id'].should == :id
9
9
  end
10
10
  it 'should map BannerPath' do
11
- klass.rules['BannerPath'].should == :path
11
+ model.rules['BannerPath'].should == :path
12
12
  end
13
13
 
14
14
  it 'should map ThumbnailPath' do
15
- klass.rules['ThumbnailPath'].should == :thumbnail_path
15
+ model.rules['ThumbnailPath'].should == :thumbnail_path
16
16
  end
17
17
 
18
18
  it 'should map VignettePath' do
19
- klass.rules['VignettePath'].should == :vignette_path
19
+ model.rules['VignettePath'].should == :vignette_path
20
20
  end
21
21
 
22
22
  it 'should map BannerType' do
23
- klass.rules['BannerType'].should == :type
23
+ model.rules['BannerType'].should == :type
24
24
  end
25
25
 
26
26
  it 'should map BannerType2' do
27
- klass.rules['BannerType2'].should == :type2
27
+ model.rules['BannerType2'].should == :type2
28
28
  end
29
29
 
30
30
  it 'should map Language' do
31
- klass.rules['Language'].should == :language
31
+ model.rules['Language'].should == :language
32
32
  end
33
33
 
34
34
  it 'should map Season' do
35
- klass.rules['Season'].should == :season
35
+ model.rules['Season'].should == :season
36
36
  end
37
37
 
38
38
  it 'should map Rating' do
39
- klass.rules['Rating'].should == :rating
39
+ model.rules['Rating'].should == :rating
40
40
  end
41
41
 
42
42
  it 'should map RatingCount' do
43
- klass.rules['RatingCount'].should == :rating_count
43
+ model.rules['RatingCount'].should == :rating_count
44
44
  end
45
45
 
46
46
  it 'should map SeriesName' do
47
- klass.rules['SeriesName'].should == :series_name
47
+ model.rules['SeriesName'].should == :series_name
48
48
  end
49
49
 
50
50
  it 'should map Colors' do
51
- klass.rules['Colors'].should == :colors
51
+ model.rules['Colors'].should == :colors
52
52
  end
53
53
  end
54
54
  end
@@ -2,28 +2,35 @@ class MappingExample < ThetvdbMapper::Mapping::Base
2
2
  end
3
3
 
4
4
  describe ThetvdbMapper::Mapping::Banner do
5
- let(:klass) { MappingExample }
5
+ let(:model) { MappingExample.new(sample: 'test') }
6
6
 
7
- describe '#map' do
7
+ describe '.map' do
8
8
  before do
9
- klass.stub(:rules).and_return(sample: :example)
9
+ model.stub(:rules).and_return(sample: :example)
10
10
  end
11
11
 
12
12
  it 'should convert hash' do
13
- klass.map(sample: 'test').should == { example: 'test' }
13
+ model.map.should == { example: 'test' }
14
14
  end
15
15
 
16
16
  it 'should call convert method if exists' do
17
- klass.stub(:respond_to?).with(:convert).and_return(true)
18
- klass.should_receive(:convert).and_return({})
19
- klass.map(sample: 'test')
17
+ model.should_receive(:convert).and_return(sample: true)
18
+ model.map
20
19
  end
21
20
  end
22
21
 
23
- describe '#convert_to_list' do
22
+ describe '.convert_to_list' do
24
23
  it 'should return correct hash' do
25
- ThetvdbMapper::Mapping::StringList.should_receive(:map).with('test')
26
- klass.convert_to_list('test')
24
+ model.stub(:list_mapping_object).with('test').and_return(double(map: true))
25
+ model.list_mapping_object('test').should_receive(:map)
26
+ model.convert_to_list('test')
27
+ end
28
+ end
29
+
30
+ describe '.list_mapping_object' do
31
+ it 'should return mapping instance' do
32
+ ThetvdbMapper::Mapping::StringList.should_receive(:new)
33
+ model.list_mapping_object('test')
27
34
  end
28
35
  end
29
36
  end