addic7ed 0.3.2 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01387dc94bdca35f99fb2b23d6758dabf22aa10d
4
- data.tar.gz: 9a4dbff972a206ba5c62e18ec407d0da1cf52179
3
+ metadata.gz: 2a4ad6c04c80ef152956ca8fce65e52870f667b3
4
+ data.tar.gz: 32ba88504a9133fa6571e4f08531f8373555837f
5
5
  SHA512:
6
- metadata.gz: e169d4ce3aeb73c28647f808f01208fe17d2f5b9e8bef402cb3bc49c4990b58bf8891728e6ebc5590faac50b8749dc20b27132e540fbd131468abd0b7c3e5b5f
7
- data.tar.gz: 0c4c6d47c3743c7465f5bab7e6da9a1d258067710a887ec1e95e2d20ee8119bb5f760aa6d36a78a554428997b16c6b18ee4a792ba8405252cc01c95a1e325358
6
+ metadata.gz: 40604453835fcd8cf137d8960ee6068528b588de0b7a1ce878823b28eb0904cb411fa555afe674acadb0dbd28b9a4313ad434a2d37235500432f324e8084cc0f
7
+ data.tar.gz: 17e682fd98b9dc14aa45d68ac54667ec4240826fa7b0419971fdaaa2b8019c039567e7efb3246900835f90b26b791b02ed7c80f9c2168fe1b3713eb64d3320cf
@@ -1,7 +1,7 @@
1
1
  module Addic7ed
2
2
  class Filename
3
3
 
4
- TVSHOW_REGEX = /\A(?<showname>.*\w)[\[\. ]+S?(?<season>\d{1,2})[-\. ]?[EX]?(?<episode>\d{2})[\]\. ]+(?<tags>.*)-(?<group>\w*)(\.\w{3})?\z/i
4
+ TVSHOW_REGEX = /\A(?<showname>.*\w)[\[\. ]+S?(?<season>\d{1,2})[-\. ]?[EX]?(?<episode>\d{2})([-\. ]?[EX]?\d{2})*[\]\. ]+(?<tags>.*)-(?<group>\w*)(\.\w{3})?\z/i
5
5
 
6
6
  attr_reader :filename, :showname, :season, :episode, :tags, :group
7
7
 
@@ -1,3 +1,3 @@
1
1
  module Addic7ed
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -2,22 +2,20 @@ require 'spec_helper'
2
2
  require './lib/addic7ed'
3
3
 
4
4
  describe Addic7ed do
5
-
6
- it 'should define SHOWS_URL' do
7
- Addic7ed::SHOWS_URL.should_not be_nil
5
+ it 'defines SHOWS_URL' do
6
+ expect(Addic7ed::SHOWS_URL).to_not be_nil
8
7
  end
9
8
 
10
- it 'should define EPISODES_URL' do
11
- Addic7ed::EPISODES_URL.should_not be_nil
9
+ it 'defines EPISODES_URL' do
10
+ expect(Addic7ed::EPISODES_URL).to_not be_nil
12
11
  end
13
12
 
14
- it 'should define EPISODE_REDIRECT_URL' do
15
- Addic7ed::EPISODE_REDIRECT_URL.should_not be_nil
13
+ it 'defines EPISODE_REDIRECT_URL' do
14
+ expect(Addic7ed::EPISODE_REDIRECT_URL).to_not be_nil
16
15
  end
17
16
 
18
- it 'should define LANGUAGES' do
19
- Addic7ed::LANGUAGES.should_not be_nil
20
- Addic7ed::LANGUAGES['fr'].should == {name: 'French', id: 8}
17
+ it 'defines LANGUAGES' do
18
+ expect(Addic7ed::LANGUAGES).to_not be_nil
19
+ expect(Addic7ed::LANGUAGES).to include 'fr' => {name: 'French', id: 8}
21
20
  end
22
-
23
21
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require './lib/addic7ed'
3
3
 
4
4
  describe Addic7ed::Episode do
5
-
6
5
  before :all do
7
6
  @filename = 'The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.mkv'
8
7
  @filename_show_not_found = 'Show.Not.Found.S03E02.720p.HDTV.x264-EVOLVE.mkv'
@@ -12,110 +11,89 @@ describe Addic7ed::Episode do
12
11
  end
13
12
 
14
13
  it 'should create valid instance given valid argument' do
15
- expect{
16
- @episode = Addic7ed::Episode.new(@filename)
17
- }.to_not raise_error
14
+ expect{ Addic7ed::Episode.new(@filename) }.to_not raise_error
18
15
  end
19
16
 
20
17
  describe '#url' do
21
-
22
- it 'should return a show localized URL given existing episode' do
23
- @episode.url('fr').should == 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8'
24
- @episode.url('es').should == 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/4'
18
+ it 'returns a show localized URL given existing episode' do
19
+ expect(@episode.url('fr')).to eq 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8'
20
+ expect(@episode.url('es')).to eq 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/4'
25
21
  end
26
22
 
27
- it 'should use French as default language' do
28
- @episode.url.should == @episode.url('fr')
23
+ it 'uses French as default language' do
24
+ expect(@episode.url).to eq @episode.url('fr')
29
25
  end
30
26
 
31
- it 'should raise LanguageNotSupported given an unsupported language code' do
32
- expect{
33
- @episode.url('aa')
34
- }.to raise_error(Addic7ed::LanguageNotSupported)
27
+ it 'raises LanguageNotSupported given an unsupported language code' do
28
+ expect{ @episode.url('aa') }.to raise_error Addic7ed::LanguageNotSupported
35
29
  end
36
-
37
30
  end
38
31
 
39
32
  describe '#subtitles' do
40
-
41
33
  it 'should return an array of Addic7ed::Subtitle given valid episode and language' do
42
- ['fr', 'en', 'it'].each do |lang|
34
+ %w{fr en it}.each do |lang|
43
35
  lang_id = Addic7ed::LANGUAGES[lang][:id]
44
36
  stub_request(:get, "http://www.addic7ed.com/serie/The_Walking_Dead/3/2/#{lang_id}")
45
37
  .to_return File.new("spec/responses/walking-dead-3-2-#{lang_id}.http")
46
38
  end
47
- @episode.subtitles('fr').size.should == 4
48
- @episode.subtitles('en').size.should == 3
49
- @episode.subtitles('it').size.should == 1
39
+ expect(@episode.subtitles('fr').size).to eq 4
40
+ expect(@episode.subtitles('en').size).to eq 3
41
+ expect(@episode.subtitles('it').size).to eq 1
50
42
  end
51
43
 
52
- it 'should use French as default language' do
53
- @episode.subtitles.should == @episode.subtitles('fr')
44
+ it 'uses French as default language' do
45
+ expect(@episode.subtitles).to eq @episode.subtitles('fr')
54
46
  end
55
47
 
56
- it 'should raise LanguageNotSupported given an unsupported language code' do
57
- expect{
58
- @episode.subtitles('aa')
59
- }.to raise_error(Addic7ed::LanguageNotSupported)
48
+ it 'raises LanguageNotSupported given an unsupported language code' do
49
+ expect{ @episode.subtitles('aa') }.to raise_error Addic7ed::LanguageNotSupported
60
50
  end
61
51
 
62
- it 'should raise EpisodeNotFound given not existing episode' do
52
+ it 'raises EpisodeNotFound given not existing episode' do
63
53
  stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/42/8')
64
54
  .to_return File.new('spec/responses/walking-dead-3-42-8.http')
65
- expect{
66
- Addic7ed::Episode.new(@filename_episode_not_found).subtitles
67
- }.to raise_error(Addic7ed::EpisodeNotFound)
55
+ expect{ Addic7ed::Episode.new(@filename_episode_not_found).subtitles }.to raise_error Addic7ed::EpisodeNotFound
68
56
  end
69
57
 
70
- it 'should raise NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
58
+ it 'raises NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
71
59
  stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/48')
72
60
  .to_return File.new('spec/responses/walking-dead-3-2-48.http')
73
- expect{
74
- @episode.subtitles('az')
75
- }.to raise_error(Addic7ed::NoSubtitleFound)
61
+ expect{ @episode.subtitles('az') }.to raise_error Addic7ed::NoSubtitleFound
76
62
  end
77
63
 
78
- it 'may raise a ParsingError, but I don\'t know how to test it :-('
79
-
64
+ it 'may raise a ParsingError, but I\'m not sure how...'
80
65
  end
81
66
 
82
67
  describe '#best_subtitle' do
83
-
84
- it 'should find the subtitle with status completed and same group name' do
68
+ it 'finds the subtitle with status completed and same group name' do
85
69
  stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8')
86
70
  .to_return File.new('spec/responses/walking-dead-3-2-8.http')
87
- @episode.best_subtitle('fr').url.should == 'http://www.addic7ed.com/original/68018/4'
71
+ expect(@episode.best_subtitle('fr').url).to eq 'http://www.addic7ed.com/original/68018/4'
88
72
  end
89
73
 
90
- it 'should find the subtitle with status completed, compatible group name and as many downloads as possible' do
74
+ it 'finds the subtitle with status completed, compatible group name and as many downloads as possible' do
91
75
  stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/4/8')
92
76
  .to_return File.new('spec/responses/walking-dead-3-4-8.http')
93
77
  compatible_episode = Addic7ed::Episode.new(@filename_compatible_group)
94
- compatible_episode.best_subtitle('fr').url.should == 'http://www.addic7ed.com/updated/8/68508/3'
78
+ expect(compatible_episode.best_subtitle('fr').url).to eq 'http://www.addic7ed.com/updated/8/68508/3'
95
79
  end
96
80
 
97
- it 'should use French as default language' do
98
- @episode.best_subtitle.should == @episode.best_subtitle('fr')
81
+ it 'uses French as default language' do
82
+ expect(@episode.best_subtitle).to eq @episode.best_subtitle('fr')
99
83
  end
100
84
 
101
- it 'should raise LanguageNotSupported given an unsupported language code' do
102
- expect{
103
- @episode.best_subtitle('aa')
104
- }.to raise_error(Addic7ed::LanguageNotSupported)
85
+ it 'raises LanguageNotSupported given an unsupported language code' do
86
+ expect{ @episode.best_subtitle('aa') }.to raise_error Addic7ed::LanguageNotSupported
105
87
  end
106
88
 
107
- it 'should raise NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
89
+ it 'raises NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
108
90
  stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/48')
109
91
  .to_return File.new('spec/responses/walking-dead-3-2-48.http')
110
- expect{
111
- @episode.best_subtitle('az')
112
- }.to raise_error(Addic7ed::NoSubtitleFound)
92
+ expect{ @episode.best_subtitle('az') }.to raise_error Addic7ed::NoSubtitleFound
113
93
  end
114
-
115
94
  end
116
95
 
117
96
  describe '#download_best_subtitle!' do
118
-
119
97
  before :each do
120
98
  WebMock.reset!
121
99
  @page_stub = stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8')
@@ -125,46 +103,44 @@ describe Addic7ed::Episode do
125
103
  # The Episode object must be re-created between every test, since redirection may modify its URI
126
104
  @reset_episode = Addic7ed::Episode.new(@filename)
127
105
  # Prevent actual disk writing
128
- Kernel.stub(:open)
106
+ allow(Kernel).to receive(:open)
129
107
  end
130
108
 
131
- it 'should get the best subtitle candidate with a network request' do
132
- Addic7ed::Episode.stub(:best_subtitle).once
109
+ it 'gets the best subtitle candidate with a network request' do
110
+ expect(@reset_episode).to receive(:best_subtitle).once.and_call_original
133
111
  @reset_episode.download_best_subtitle!('fr')
134
- @page_stub.should have_been_requested
135
- @sub_stub.should have_been_requested
112
+ expect(@page_stub).to have_been_requested
113
+ expect(@sub_stub).to have_been_requested
136
114
  end
137
115
 
138
- it 'should raise DownloadError when a network error happens' do
116
+ it 'raises DownloadError when a network error happens' do
139
117
  stub_request(:get, 'http://www.addic7ed.com/original/68018/4').to_timeout
140
118
  expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::DownloadError
141
119
  end
142
120
 
143
- it 'should be called recursively' do
121
+ it 'is called recursively' do
144
122
  stub_request(:get, 'http://www.addic7ed.com/original/68018/4').to_return File.new('spec/responses/basic_redirection.http')
145
123
  stub_request(:get, 'http://www.addic7ed.com/original/68018/4.redirected').to_return File.new('spec/responses/walking-dead-3-2-8_best_subtitle.http')
146
- Addic7ed::Episode.stub(:download_best_subtitle!).twice.and_call_original
124
+ expect(@reset_episode).to receive(:download_best_subtitle!).twice.and_call_original
147
125
  @reset_episode.download_best_subtitle!('fr')
148
126
  end
149
127
 
150
- it 'should raise HTTPError when stuck in a HTTP redirections loop' do
128
+ it 'raises HTTPError when stuck in a HTTP redirections loop' do
151
129
  stub_request(:get, 'http://www.addic7ed.com/original/68018/4')
152
130
  .to_return File.new('spec/responses/redirection_loop.http')
153
- expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error(Addic7ed::HTTPError)
131
+ expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::HTTPError
154
132
  end
155
133
 
156
- it 'should create a new file on disk' do
134
+ it 'creates a new file on disk' do
157
135
  file = double('file')
158
- Kernel.should_receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_yield(file)
159
- file.should_receive(:<<)
136
+ expect(Kernel).to receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_yield(file)
137
+ expect(file).to receive(:<<)
160
138
  @reset_episode.download_best_subtitle!('fr')
161
139
  end
162
140
 
163
- it 'should raise SubtitleCannotBeSaved when a disk error happens' do
164
- Kernel.should_receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_raise('Persmission denied')
141
+ it 'raises SubtitleCannotBeSaved when a disk error happens' do
142
+ expect(Kernel).to receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_raise('Persmission denied')
165
143
  expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::SubtitleCannotBeSaved
166
144
  end
167
-
168
145
  end
169
-
170
- end
146
+ end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require './lib/addic7ed'
3
3
 
4
4
  describe Addic7ed::Filename do
5
-
6
5
  before :all do
7
6
  # Valid filenames
8
7
  @filename = 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
@@ -23,6 +22,8 @@ describe Addic7ed::Filename do
23
22
  @filename_full_path = '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
24
23
  @filename_relative_path = '../Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
25
24
  @filename_no_extension = 'Californication.S06E07.720p.HDTV.x264-2HD'
25
+ @filename_double_episode = 'Revenge.S02E21E22.720p.HDTV.X264-DIMENSION.mkv'
26
+ @filename_double_episode_with_dash = 'Revenge.S02E21-22.720p.HDTV.X264-DIMENSION.mkv'
26
27
  # Invalid filenames
27
28
  @filename_no_showname = '.S06E07.720p.HDTV.x264-2HD.mkv'
28
29
  @filename_no_season = 'Californication.E07.720p.HDTV.x264-2HD.mkv'
@@ -39,309 +40,270 @@ describe Addic7ed::Filename do
39
40
  @filename_showname_year_US = 'The.Hour.2011.US.S01E03.REPACK.HDTV.XviD-FoV.avi'
40
41
  end
41
42
 
42
- it 'should succeed given valid argument' do
43
- expect {
44
- @file = Addic7ed::Filename.new(@filename)
45
- }.to_not raise_error
46
- @file.showname.should == 'Californication'
47
- @file.season.should == 6
48
- @file.episode.should == 7
49
- @file.tags.should == ['720P', 'HDTV', 'X264']
50
- @file.group.should == '2HD'
51
- end
43
+ describe '#initialize' do
44
+ it 'succeeds given valid argument' do
45
+ expect{ @file = Addic7ed::Filename.new(@filename) }.to_not raise_error
46
+ expect(@file.showname).to eq 'Californication'
47
+ expect(@file.season ).to eq 6
48
+ expect(@file.episode ).to eq 7
49
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
50
+ expect(@file.group ).to eq '2HD'
51
+ end
52
52
 
53
- it 'should succeed given filename with x notation' do
54
- expect {
55
- @file = Addic7ed::Filename.new(@filename_x)
56
- }.to_not raise_error
57
- @file.showname.should == 'Californication'
58
- @file.season.should == 6
59
- @file.episode.should == 7
60
- @file.tags.should == ['720P', 'HDTV', 'X264']
61
- @file.group.should == '2HD'
62
- end
53
+ it 'succeeds given filename with x notation' do
54
+ expect{ @file = Addic7ed::Filename.new(@filename_x) }.to_not raise_error
55
+ expect(@file.showname).to eq 'Californication'
56
+ expect(@file.season ).to eq 6
57
+ expect(@file.episode ).to eq 7
58
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
59
+ expect(@file.group ).to eq '2HD'
60
+ end
63
61
 
64
- it 'should succeed given filename with 3-digits notation' do
65
- expect {
66
- @file = Addic7ed::Filename.new(@filename_3digits)
67
- }.to_not raise_error
68
- @file.showname.should == 'Californication'
69
- @file.season.should == 6
70
- @file.episode.should == 7
71
- @file.tags.should == ['720P', 'HDTV', 'X264']
72
- @file.group.should == '2HD'
73
- end
62
+ it 'succeeds given filename with 3-digits notation' do
63
+ expect{ @file = Addic7ed::Filename.new(@filename_3digits) }.to_not raise_error
64
+ expect(@file.showname).to eq 'Californication'
65
+ expect(@file.season ).to eq 6
66
+ expect(@file.episode ).to eq 7
67
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
68
+ expect(@file.group ).to eq '2HD'
69
+ end
74
70
 
75
- it 'should succeed given filename with brackets notation' do
76
- expect {
77
- @file = Addic7ed::Filename.new(@filename_brackets)
78
- }.to_not raise_error
79
- @file.showname.should == 'Californication'
80
- @file.season.should == 6
81
- @file.episode.should == 7
82
- @file.tags.should == ['720P', 'HDTV', 'X264']
83
- @file.group.should == '2HD'
84
- end
71
+ it 'succeeds given filename with brackets notation' do
72
+ expect{ @file = Addic7ed::Filename.new(@filename_brackets) }.to_not raise_error
73
+ expect(@file.showname).to eq 'Californication'
74
+ expect(@file.season ).to eq 6
75
+ expect(@file.episode ).to eq 7
76
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
77
+ expect(@file.group ).to eq '2HD'
78
+ end
85
79
 
86
- it 'should succeed given filename with brackets and x notation' do
87
- expect {
88
- @file = Addic7ed::Filename.new(@filename_x_brackets)
89
- }.to_not raise_error
90
- @file.showname.should == 'Californication'
91
- @file.season.should == 6
92
- @file.episode.should == 7
93
- @file.tags.should == ['720P', 'HDTV', 'X264']
94
- @file.group.should == '2HD'
95
- end
80
+ it 'succeeds given filename with brackets and x notation' do
81
+ expect{ @file = Addic7ed::Filename.new(@filename_x_brackets) }.to_not raise_error
82
+ expect(@file.showname).to eq 'Californication'
83
+ expect(@file.season ).to eq 6
84
+ expect(@file.episode ).to eq 7
85
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
86
+ expect(@file.group ).to eq '2HD'
87
+ end
96
88
 
97
- it 'should succeed given filename with brackets and 3-digits notation' do
98
- expect {
99
- @file = Addic7ed::Filename.new(@filename_3digits_brackets)
100
- }.to_not raise_error
101
- @file.showname.should == 'Californication'
102
- @file.season.should == 6
103
- @file.episode.should == 7
104
- @file.tags.should == ['720P', 'HDTV', 'X264']
105
- @file.group.should == '2HD'
106
- end
89
+ it 'succeeds given filename with brackets and 3-digits notation' do
90
+ expect{ @file = Addic7ed::Filename.new(@filename_3digits_brackets) }.to_not raise_error
91
+ expect(@file.showname).to eq 'Californication'
92
+ expect(@file.season ).to eq 6
93
+ expect(@file.episode ).to eq 7
94
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
95
+ expect(@file.group ).to eq '2HD'
96
+ end
107
97
 
108
- it 'should succeed given filename with brackets notation and space separator' do
109
- expect {
110
- @file = Addic7ed::Filename.new(@filename_brackets_spaces)
111
- }.to_not raise_error
112
- @file.showname.should == 'Californication'
113
- @file.season.should == 6
114
- @file.episode.should == 7
115
- @file.tags.should == ['720P', 'HDTV', 'X264']
116
- @file.group.should == '2HD'
117
- end
98
+ it 'succeeds given filename with brackets notation and space separator' do
99
+ expect{ @file = Addic7ed::Filename.new(@filename_brackets_spaces) }.to_not raise_error
100
+ expect(@file.showname).to eq 'Californication'
101
+ expect(@file.season ).to eq 6
102
+ expect(@file.episode ).to eq 7
103
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
104
+ expect(@file.group ).to eq '2HD'
105
+ end
118
106
 
119
- it 'should succeed given filename with brackets and x notation and space separator' do
120
- expect {
121
- @file = Addic7ed::Filename.new(@filename_x_brackets_spaces)
122
- }.to_not raise_error
123
- @file.showname.should == 'Californication'
124
- @file.season.should == 6
125
- @file.episode.should == 7
126
- @file.tags.should == ['720P', 'HDTV', 'X264']
127
- @file.group.should == '2HD'
128
- end
107
+ it 'succeeds given filename with brackets and x notation and space separator' do
108
+ expect{ @file = Addic7ed::Filename.new(@filename_x_brackets_spaces) }.to_not raise_error
109
+ expect(@file.showname).to eq 'Californication'
110
+ expect(@file.season ).to eq 6
111
+ expect(@file.episode ).to eq 7
112
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
113
+ expect(@file.group ).to eq '2HD'
114
+ end
129
115
 
130
- it 'should succeed given filename with brackets and 3-digits notation and space separator' do
131
- expect {
132
- @file = Addic7ed::Filename.new(@filename_3digits_brackets_spaces)
133
- }.to_not raise_error
134
- @file.showname.should == 'Californication'
135
- @file.season.should == 6
136
- @file.episode.should == 7
137
- @file.tags.should == ['720P', 'HDTV', 'X264']
138
- @file.group.should == '2HD'
139
- end
116
+ it 'succeeds given filename with brackets and 3-digits notation and space separator' do
117
+ expect{ @file = Addic7ed::Filename.new(@filename_3digits_brackets_spaces) }.to_not raise_error
118
+ expect(@file.showname).to eq 'Californication'
119
+ expect(@file.season ).to eq 6
120
+ expect(@file.episode ).to eq 7
121
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
122
+ expect(@file.group ).to eq '2HD'
123
+ end
140
124
 
141
- it 'should succeed given lowercase filename' do
142
- expect {
143
- @file = Addic7ed::Filename.new(@filename_lowercase)
144
- }.to_not raise_error
145
- @file.showname.should == 'californication'
146
- @file.season.should == 6
147
- @file.episode.should == 7
148
- @file.tags.should == ['720P', 'HDTV', 'X264']
149
- @file.group.should == '2HD'
150
- end
125
+ it 'succeeds given lowercase filename' do
126
+ expect{ @file = Addic7ed::Filename.new(@filename_lowercase) }.to_not raise_error
127
+ expect(@file.showname).to eq 'californication'
128
+ expect(@file.season ).to eq 6
129
+ expect(@file.episode ).to eq 7
130
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
131
+ expect(@file.group ).to eq '2HD'
132
+ end
151
133
 
152
- it 'should succeed given lowercase filename with x notation' do
153
- expect {
154
- @file = Addic7ed::Filename.new(@filename_lowercase_x)
155
- }.to_not raise_error
156
- @file.showname.should == 'californication'
157
- @file.season.should == 6
158
- @file.episode.should == 7
159
- @file.tags.should == ['720P', 'HDTV', 'X264']
160
- @file.group.should == '2HD'
161
- end
134
+ it 'succeeds given lowercase filename with x notation' do
135
+ expect{ @file = Addic7ed::Filename.new(@filename_lowercase_x) }.to_not raise_error
136
+ expect(@file.showname).to eq 'californication'
137
+ expect(@file.season ).to eq 6
138
+ expect(@file.episode ).to eq 7
139
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
140
+ expect(@file.group ).to eq '2HD'
141
+ end
162
142
 
163
- it 'should succeed given filename with showname containing multiple words' do
164
- expect {
165
- @file = Addic7ed::Filename.new(@filename_multiple_words)
166
- }.to_not raise_error
167
- @file.showname.should == 'The Walking Dead'
168
- @file.season.should == 3
169
- @file.episode.should == 11
170
- @file.tags.should == ['720P', 'HDTV', 'X264']
171
- @file.group.should == 'EVOLVE'
172
- end
143
+ it 'succeeds given filename with showname containing multiple words' do
144
+ expect{ @file = Addic7ed::Filename.new(@filename_multiple_words) }.to_not raise_error
145
+ expect(@file.showname).to eq 'The Walking Dead'
146
+ expect(@file.season ).to eq 3
147
+ expect(@file.episode ).to eq 11
148
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
149
+ expect(@file.group ).to eq 'EVOLVE'
150
+ end
173
151
 
174
- it 'should succeed given filename with showname containing multiple words with space separator' do
175
- expect {
176
- @file = Addic7ed::Filename.new(@filename_multiple_words_spaces)
177
- }.to_not raise_error
178
- @file.showname.should == 'The Walking Dead'
179
- @file.season.should == 3
180
- @file.episode.should == 11
181
- @file.tags.should == ['720P', 'HDTV', 'X264']
182
- @file.group.should == 'EVOLVE'
183
- end
152
+ it 'succeeds given filename with showname containing multiple words with space separator' do
153
+ expect{ @file = Addic7ed::Filename.new(@filename_multiple_words_spaces) }.to_not raise_error
154
+ expect(@file.showname).to eq 'The Walking Dead'
155
+ expect(@file.season ).to eq 3
156
+ expect(@file.episode ).to eq 11
157
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
158
+ expect(@file.group ).to eq 'EVOLVE'
159
+ end
184
160
 
185
- it 'should succeed given filename with showname containing only numbers' do
186
- expect {
187
- @file = Addic7ed::Filename.new(@filename_numbers_only)
188
- }.to_not raise_error
189
- @file.showname.should == '90210'
190
- @file.season.should == 5
191
- @file.episode.should == 12
192
- @file.tags.should == ['720P', 'HDTV', 'X264']
193
- @file.group.should == 'DIMENSION'
194
- end
161
+ it 'succeeds given filename with showname containing only numbers' do
162
+ expect{ @file = Addic7ed::Filename.new(@filename_numbers_only) }.to_not raise_error
163
+ expect(@file.showname).to eq '90210'
164
+ expect(@file.season ).to eq 5
165
+ expect(@file.episode ).to eq 12
166
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
167
+ expect(@file.group ).to eq 'DIMENSION'
168
+ end
195
169
 
196
- it 'should succeed given filename with showname containing production year' do
197
- expect {
198
- @file = Addic7ed::Filename.new(@filename_showname_year)
199
- }.to_not raise_error
200
- @file.showname.should == 'The Americans 2013'
201
- @file.season.should == 1
202
- @file.episode.should == 4
203
- @file.tags.should == ['720P', 'HDTV', 'X264']
204
- @file.group.should == 'DIMENSION'
205
- end
170
+ it 'succeeds given filename with showname containing production year' do
171
+ expect{ @file = Addic7ed::Filename.new(@filename_showname_year) }.to_not raise_error
172
+ expect(@file.showname).to eq 'The Americans 2013'
173
+ expect(@file.season ).to eq 1
174
+ expect(@file.episode ).to eq 4
175
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
176
+ expect(@file.group ).to eq 'DIMENSION'
177
+ end
206
178
 
207
- it 'should succeed given filename containing full path' do
208
- expect {
209
- @file = Addic7ed::Filename.new(@filename_full_path)
210
- }.to_not raise_error
211
- @file.showname.should == 'Californication'
212
- @file.season.should == 6
213
- @file.episode.should == 7
214
- @file.tags.should == ['720P', 'HDTV', 'X264']
215
- @file.group.should == '2HD'
216
- end
179
+ it 'succeeds given filename containing full path' do
180
+ expect{ @file = Addic7ed::Filename.new(@filename_full_path) }.to_not raise_error
181
+ expect(@file.showname).to eq 'Californication'
182
+ expect(@file.season ).to eq 6
183
+ expect(@file.episode ).to eq 7
184
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
185
+ expect(@file.group ).to eq '2HD'
186
+ end
217
187
 
218
- it 'should succeed given filename containing relative path' do
219
- expect {
220
- @file = Addic7ed::Filename.new(@filename_relative_path)
221
- }.to_not raise_error
222
- @file.showname.should == 'Californication'
223
- @file.season.should == 6
224
- @file.episode.should == 7
225
- @file.tags.should == ['720P', 'HDTV', 'X264']
226
- @file.group.should == '2HD'
227
- end
188
+ it 'succeeds given filename containing relative path' do
189
+ expect{ @file = Addic7ed::Filename.new(@filename_relative_path) }.to_not raise_error
190
+ expect(@file.showname).to eq 'Californication'
191
+ expect(@file.season ).to eq 6
192
+ expect(@file.episode ).to eq 7
193
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
194
+ expect(@file.group ).to eq '2HD'
195
+ end
228
196
 
229
- it 'should succeed given filename containing no extension' do
230
- expect {
231
- @file = Addic7ed::Filename.new(@filename_no_extension)
232
- }.to_not raise_error
233
- @file.showname.should == 'Californication'
234
- @file.season.should == 6
235
- @file.episode.should == 7
236
- @file.tags.should == ['720P', 'HDTV', 'X264']
237
- @file.group.should == '2HD'
238
- end
197
+ it 'succeeds given filename containing no extension' do
198
+ expect{ @file = Addic7ed::Filename.new(@filename_no_extension) }.to_not raise_error
199
+ expect(@file.showname).to eq 'Californication'
200
+ expect(@file.season ).to eq 6
201
+ expect(@file.episode ).to eq 7
202
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
203
+ expect(@file.group ).to eq '2HD'
204
+ end
239
205
 
240
- it 'should fail given filename with no showname' do
241
- expect {
242
- @file = Addic7ed::Filename.new(@filename_no_showname)
243
- }.to raise_error
244
- end
206
+ it 'succeeds given filename which is a double episode' do
207
+ expect{ @file = Addic7ed::Filename.new(@filename_double_episode) }.to_not raise_error
208
+ expect(@file.showname).to eq 'Revenge'
209
+ expect(@file.season ).to eq 2
210
+ expect(@file.episode ).to eq 21
211
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
212
+ expect(@file.group ).to eq 'DIMENSION'
213
+ end
245
214
 
246
- it 'should fail given filename with no season number' do
247
- expect {
248
- @file = Addic7ed::Filename.new(@filename_no_season)
249
- }.to raise_error
250
- end
215
+ it 'succeeds given filename which is a double episode (with a dash)' do
216
+ expect{ @file = Addic7ed::Filename.new(@filename_double_episode_with_dash) }.to_not raise_error
217
+ expect(@file.showname).to eq 'Revenge'
218
+ expect(@file.season ).to eq 2
219
+ expect(@file.episode ).to eq 21
220
+ expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
221
+ expect(@file.group ).to eq 'DIMENSION'
222
+ end
251
223
 
252
- it 'should raise InvalidFilename given filename with no episode number' do
253
- expect {
254
- @file = Addic7ed::Filename.new(@filename_no_episode)
255
- }.to raise_error(Addic7ed::InvalidFilename)
256
- end
224
+ it 'fails given filename with no showname' do
225
+ expect{ Addic7ed::Filename.new(@filename_no_showname) }.to raise_error Addic7ed::InvalidFilename
226
+ end
257
227
 
258
- it 'should raise InvalidFilename given filename with no tags' do
259
- expect {
260
- @file = Addic7ed::Filename.new(@filename_no_tags)
261
- }.to raise_error(Addic7ed::InvalidFilename)
262
- end
228
+ it 'fails given filename with no season number' do
229
+ expect{ Addic7ed::Filename.new(@filename_no_season) }.to raise_error Addic7ed::InvalidFilename
230
+ end
263
231
 
264
- it 'should raise InvalidFilename given filename with no group' do
265
- expect {
266
- @file = Addic7ed::Filename.new(@filename_no_group)
267
- }.to raise_error(Addic7ed::InvalidFilename)
268
- end
232
+ it 'raises InvalidFilename given filename with no episode number' do
233
+ expect{ Addic7ed::Filename.new(@filename_no_episode) }.to raise_error Addic7ed::InvalidFilename
234
+ end
269
235
 
270
- describe '#encoded_filename' do
236
+ it 'raises InvalidFilename given filename with no tags' do
237
+ expect{ Addic7ed::Filename.new(@filename_no_tags) }.to raise_error Addic7ed::InvalidFilename
238
+ end
271
239
 
272
- it 'should change all spaces to underscores' do
273
- Addic7ed::Filename.new(@filename_multiple_words).encoded_showname.should == 'The_Walking_Dead'
240
+ it 'raises InvalidFilename given filename with no group' do
241
+ expect{ Addic7ed::Filename.new(@filename_no_group) }.to raise_error Addic7ed::InvalidFilename
274
242
  end
243
+ end
275
244
 
276
- it 'should wrap country code with parenthesis' do
277
- Addic7ed::Filename.new(@filename_showname_US).encoded_showname.should == 'Shameless_(US)'
245
+ describe '#encoded_filename' do
246
+ it 'changes all spaces to underscores' do
247
+ expect(Addic7ed::Filename.new(@filename_multiple_words).encoded_showname).to eq 'The_Walking_Dead'
278
248
  end
279
249
 
280
- it 'should detect country code even in lowercase' do
281
- Addic7ed::Filename.new(@filename_showname_US_lowercase).encoded_showname.should == 'shameless_(us)'
250
+ it 'wraps country code with parenthesis' do
251
+ expect(Addic7ed::Filename.new(@filename_showname_US).encoded_showname).to eq 'Shameless_(US)'
282
252
  end
283
253
 
284
- it 'should remove country code for the original show (usually UK)' do
285
- Addic7ed::Filename.new(@filename_showname_UK).encoded_showname.should == 'Shameless'
254
+ it 'detects country code even in lowercase' do
255
+ expect(Addic7ed::Filename.new(@filename_showname_US_lowercase).encoded_showname).to eq 'shameless_(us)'
286
256
  end
287
257
 
288
- it 'should remove production year' do
289
- Addic7ed::Filename.new(@filename_showname_year).encoded_showname.should == 'The_Americans'
258
+ it 'removes country code for the original show (usually UK)' do
259
+ expect(Addic7ed::Filename.new(@filename_showname_UK).encoded_showname).to eq 'Shameless'
290
260
  end
291
261
 
292
- it 'should handle when both country code and production year are present' do
293
- Addic7ed::Filename.new(@filename_showname_UK_year).encoded_showname.should == 'The_Hour'
294
- Addic7ed::Filename.new(@filename_showname_year_UK).encoded_showname.should == 'The_Hour'
295
- Addic7ed::Filename.new(@filename_showname_US_year).encoded_showname.should == 'The_Hour_(US)'
296
- Addic7ed::Filename.new(@filename_showname_year_US).encoded_showname.should == 'The_Hour_(US)'
262
+ it 'removes production year' do
263
+ expect(Addic7ed::Filename.new(@filename_showname_year).encoded_showname).to eq 'The_Americans'
297
264
  end
298
265
 
266
+ it 'handles when both country code and production year are present' do
267
+ expect(Addic7ed::Filename.new(@filename_showname_UK_year).encoded_showname).to eq 'The_Hour'
268
+ expect(Addic7ed::Filename.new(@filename_showname_year_UK).encoded_showname).to eq 'The_Hour'
269
+ expect(Addic7ed::Filename.new(@filename_showname_US_year).encoded_showname).to eq 'The_Hour_(US)'
270
+ expect(Addic7ed::Filename.new(@filename_showname_year_US).encoded_showname).to eq 'The_Hour_(US)'
271
+ end
299
272
  end
300
273
 
301
274
  describe '#basename' do
302
-
303
- it 'should return only file name given a full path' do
304
- Addic7ed::Filename.new(@filename_full_path).basename.should == 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
275
+ it 'returns only file name given a full path' do
276
+ expect(Addic7ed::Filename.new(@filename_full_path).basename).to eq 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
305
277
  end
306
-
307
278
  end
308
279
 
309
280
  describe '#dirname' do
310
-
311
- it 'should return only path given a full path' do
312
- Addic7ed::Filename.new(@filename_full_path).dirname.should == '/data/public/Series/Californication/Saison 06'
281
+ it 'returns only path given a full path' do
282
+ expect(Addic7ed::Filename.new(@filename_full_path).dirname).to eq '/data/public/Series/Californication/Saison 06'
313
283
  end
314
-
315
284
  end
316
285
 
317
286
  describe '#extname' do
318
-
319
- it 'should return only file extension given a full path' do
320
- Addic7ed::Filename.new(@filename_full_path).extname.should == '.mkv'
287
+ it 'returns only file extension given a full path' do
288
+ expect(Addic7ed::Filename.new(@filename_full_path).extname).to eq '.mkv'
321
289
  end
322
-
323
290
  end
324
291
 
325
292
  describe '#to_s' do
326
-
327
- it 'should return file name as a string' do
328
- Addic7ed::Filename.new(@filename_full_path).to_s.should == '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
293
+ it 'returns file name as a string' do
294
+ expect(Addic7ed::Filename.new(@filename_full_path).to_s).to eq '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
329
295
  end
330
-
331
296
  end
332
297
 
333
298
  describe '#inspect' do
334
-
335
- it 'should print a human-readable detailed version' do
336
- Addic7ed::Filename.new(@filename).inspect.should ==
299
+ it 'prints a human-readable detailed version' do
300
+ expect(Addic7ed::Filename.new(@filename).inspect).to eq(
337
301
  'Guesses for Californication.S06E07.720p.HDTV.x264-2HD.mkv:
338
302
  show: Californication
339
303
  season: 6
340
304
  episode: 7
341
305
  tags: ["720P", "HDTV", "X264"]
342
- group: 2HD'
306
+ group: 2HD')
343
307
  end
344
-
345
308
  end
346
-
347
309
  end
@@ -2,174 +2,147 @@ require 'spec_helper'
2
2
  require './lib/addic7ed'
3
3
 
4
4
  describe Addic7ed::Subtitle do
5
-
6
5
  describe '#normalized_version' do
7
-
8
- it 'should upcase the version string' do
9
- Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '', '0').version.should == 'DIMENSION'
6
+ it 'upcases the version string' do
7
+ expect(Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '', '0').version).to eq 'DIMENSION'
10
8
  end
11
9
 
12
- it 'should remove heading and trailing dots' do
13
- Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
14
- Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '', '0').version.should == 'DIMENSION'
15
- Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '', '0').version.should == 'DIMENSION'
10
+ it 'removes heading and trailing dots' do
11
+ expect(Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
12
+ expect(Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '', '0').version).to eq 'DIMENSION'
13
+ expect(Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '', '0').version).to eq 'DIMENSION'
16
14
  end
17
15
 
18
- it 'should remove heading and trailing whitespaces' do
19
- Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
20
- Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '', '0').version.should == 'DIMENSION'
21
- Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '', '0').version.should == 'DIMENSION'
16
+ it 'removes heading and trailing whitespaces' do
17
+ expect(Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
18
+ expect(Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '', '0').version).to eq 'DIMENSION'
19
+ expect(Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '', '0').version).to eq 'DIMENSION'
22
20
  end
23
21
 
24
- it 'should remove heading and trailing dashes' do
25
- Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
26
- Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '', '0').version.should == 'DIMENSION'
27
- Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '', '0').version.should == 'DIMENSION'
22
+ it 'removes heading and trailing dashes' do
23
+ expect(Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
24
+ expect(Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '', '0').version).to eq 'DIMENSION'
25
+ expect(Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '', '0').version).to eq 'DIMENSION'
28
26
  end
29
27
 
30
- it 'should automatically remove "720p" in version string' do
31
- Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
32
- Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
33
- Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '', '0').version.should == 'DIMENSION'
34
- Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '', '0').version.should == 'DIMENSION'
28
+ it 'automatically removes "720p" in version string' do
29
+ expect(Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
30
+ expect(Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
31
+ expect(Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '', '0').version).to eq 'DIMENSION'
32
+ expect(Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '', '0').version).to eq 'DIMENSION'
35
33
  end
36
34
 
37
- it 'should automatically remove "HDTV" in version string' do
38
- Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
39
- Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
40
- Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '', '0').version.should == 'DIMENSION'
41
- Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '', '0').version.should == 'DIMENSION'
35
+ it 'automatically removes "HDTV" in version string' do
36
+ expect(Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
37
+ expect(Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
38
+ expect(Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '', '0').version).to eq 'DIMENSION'
39
+ expect(Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '', '0').version).to eq 'DIMENSION'
42
40
  end
43
41
 
44
- it 'should automatically remove "x264" in version string' do
45
- Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
46
- Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
47
- Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
48
- Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
49
- Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '', '0').version.should == 'DIMENSION'
50
- Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '', '0').version.should == 'DIMENSION'
51
- Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '', '0').version.should == 'DIMENSION'
52
- Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '', '0').version.should == 'DIMENSION'
42
+ it 'automatically removes "x264" in version string' do
43
+ expect(Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
44
+ expect(Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
45
+ expect(Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
46
+ expect(Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
47
+ expect(Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '', '0').version).to eq 'DIMENSION'
48
+ expect(Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '', '0').version).to eq 'DIMENSION'
49
+ expect(Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '', '0').version).to eq 'DIMENSION'
50
+ expect(Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '', '0').version).to eq 'DIMENSION'
53
51
  end
54
52
 
55
- it 'should automatically remove "PROPER" in version string' do
56
- Addic7ed::Subtitle.new('PROPER DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
57
- Addic7ed::Subtitle.new('Proper DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
58
- Addic7ed::Subtitle.new('DIMENSION PROPER', '', '', '', '', '0').version.should == 'DIMENSION'
59
- Addic7ed::Subtitle.new('DIMENSION Proper', '', '', '', '', '0').version.should == 'DIMENSION'
53
+ it 'automatically removes "PROPER" in version string' do
54
+ expect(Addic7ed::Subtitle.new('PROPER DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
55
+ expect(Addic7ed::Subtitle.new('Proper DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
56
+ expect(Addic7ed::Subtitle.new('DIMENSION PROPER', '', '', '', '', '0').version).to eq 'DIMENSION'
57
+ expect(Addic7ed::Subtitle.new('DIMENSION Proper', '', '', '', '', '0').version).to eq 'DIMENSION'
60
58
  end
61
59
 
62
- it 'should automatically remove "Version" prefix in version string' do
63
- Addic7ed::Subtitle.new('Version DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
60
+ it 'automatically removes "Version" prefix in version string' do
61
+ expect(Addic7ed::Subtitle.new('Version DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
64
62
  end
65
-
66
63
  end
67
64
 
68
65
  describe '#to_s' do
69
-
70
- it 'should print a human readable version' do
66
+ it 'prints a human readable version' do
71
67
  sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', 'http://some.fancy.url', 'http://addic7ed.com', '42')
72
- expect(sub.to_s).to eql("http://some.fancy.url\t->\tDIMENSION (fr, Completed) [42 downloads] (via http://addic7ed.com)")
68
+ expect(sub.to_s).to eq "http://some.fancy.url\t->\tDIMENSION (fr, Completed) [42 downloads] (via http://addic7ed.com)"
73
69
  end
74
-
75
70
  end
76
71
 
77
72
  describe '#works_for?' do
78
-
79
73
  context 'when incomplete' do
74
+ before(:all) { @sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10') }
80
75
 
81
- before :all do
82
- @sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10')
83
- end
84
-
85
- it 'should return false' do
76
+ it 'returns false' do
86
77
  expect(@sub.works_for?).to be false
87
78
  end
88
-
89
79
  end
90
80
 
91
81
  context 'when completed' do
82
+ before(:all) { @sub = Addic7ed::Subtitle.new('DIMENSION', '', 'Completed', '', '', '10') }
92
83
 
93
- before :all do
94
- @sub = Addic7ed::Subtitle.new('DIMENSION', '', 'Completed', '', '', '10')
95
- end
96
-
97
- it 'should return true given the exact same version' do
84
+ it 'returns true given the exact same version' do
98
85
  expect(@sub.works_for? 'DIMENSION').to be true
99
86
  end
100
87
 
101
- it 'should return true given a compatible version' do
88
+ it 'returns true given a compatible version' do
102
89
  expect(@sub.works_for? 'LOL').to be true
103
90
  end
104
91
 
105
- it 'should return true when the subtitle is for a PROPER version' do
92
+ it 'returns true when the subtitle is for a PROPER version' do
106
93
  sub = Addic7ed::Subtitle.new('PROPER DIMENSION', '', 'Completed', '', '', '10')
107
94
  expect(sub.works_for? 'DIMENSION').to be true
108
95
  expect(sub.works_for? 'LOL').to be true
109
96
  end
110
97
 
111
- it 'should return false given an incompatible version' do
98
+ it 'returns false given an incompatible version' do
112
99
  expect(@sub.works_for? 'EVOLVE').to be false
113
100
  end
114
-
115
101
  end
116
-
117
102
  end
118
103
 
119
-
120
104
  describe '#can_replace?' do
121
-
122
105
  context 'when incomplete' do
123
-
124
- it 'should return false' do
106
+ it 'returns false' do
125
107
  sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10')
126
108
  any_other_sub = Addic7ed::Subtitle.new('', '', '', '', '', '0')
127
109
  expect(sub.can_replace? any_other_sub).to be false
128
110
  end
129
-
130
111
  end
131
112
 
132
113
  context 'when completed' do
114
+ before(:all) { @sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '10') }
133
115
 
134
- before :all do
135
- @sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '10')
136
- end
137
-
138
- it 'should return true given no other_sub' do
116
+ it 'returns true given no other_sub' do
139
117
  expect(@sub.can_replace? nil).to be true
140
118
  end
141
119
 
142
- it 'should return false given other_sub for another language' do
120
+ it 'returns false given other_sub for another language' do
143
121
  other_sub = Addic7ed::Subtitle.new('DIMENSION', 'en', 'Completed', '', '', '10')
144
122
  expect(@sub.can_replace? other_sub).to be false
145
123
  end
146
124
 
147
- it 'should return false given other_sub for incompatible version' do
125
+ it 'returns false given other_sub for incompatible version' do
148
126
  other_sub = Addic7ed::Subtitle.new('EVOLVE', 'fr', 'Completed', '', '', '10')
149
127
  expect(@sub.can_replace? other_sub).to be false
150
128
  end
151
129
 
152
130
  context 'given other_sub language & version compatible' do
153
-
154
- it 'should return false given other_sub featured by Addic7ed' do
131
+ it 'returns false given other_sub featured by Addic7ed' do
155
132
  other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', 'http://addic7ed.com', '10')
156
133
  expect(@sub.can_replace? other_sub).to be false
157
134
  end
158
135
 
159
- it 'should return false given other_sub with more downloads' do
136
+ it 'returns false given other_sub with more downloads' do
160
137
  other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '20')
161
138
  expect(@sub.can_replace? other_sub).to be false
162
139
  end
163
140
 
164
- it 'should return true given other_sub with less downloads' do
141
+ it 'returns true given other_sub with less downloads' do
165
142
  other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '5')
166
143
  expect(@sub.can_replace? other_sub).to be true
167
144
  end
168
-
169
145
  end
170
-
171
146
  end
172
-
173
147
  end
174
-
175
148
  end
data/spec/spec_helper.rb CHANGED
@@ -8,11 +8,13 @@ WebMock.disable_net_connect!(allow_localhost: true)
8
8
 
9
9
  RSpec.configure do |config|
10
10
  # Use color in STDOUT
11
- config.color_enabled = true
11
+ config.color = true
12
12
 
13
13
  # Use color not only in STDOUT but also in pagers and files
14
14
  config.tty = true
15
15
 
16
16
  # Use the specified formatter
17
17
  config.formatter = :documentation # :progress, :html, :textmate
18
+
19
+ config.raise_errors_for_deprecations!
18
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addic7ed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Baudino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.2.0
120
+ rubygems_version: 2.2.2
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Addic7ed auto-downloader