torrents 1.0.1 → 1.0.2
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.
- data/lib/torrents/container.rb +2 -1
- data/spec/torrent_spec.rb +11 -0
- data/torrents.gemspec +1 -1
- metadata +1 -1
data/lib/torrents/container.rb
CHANGED
@@ -233,7 +233,8 @@ module Container
|
|
233
233
|
# Read more about it here: https://github.com/oleander/Undertexter
|
234
234
|
# Return type: A single Undertexter object or nil
|
235
235
|
def subtitle(option = :english)
|
236
|
-
@subtitle
|
236
|
+
@subtitle = {} unless @subtitle
|
237
|
+
@subtitle[option] ||= Undertexter.find(self.imdb_id, language: option).based_on(self.title)
|
237
238
|
end
|
238
239
|
|
239
240
|
# Returns the torrent for the torrent
|
data/spec/torrent_spec.rb
CHANGED
@@ -170,6 +170,17 @@ describe Container::Torrent do
|
|
170
170
|
|
171
171
|
torrent.subtitle(:swedish).title.should eq("a subtitle")
|
172
172
|
end
|
173
|
+
|
174
|
+
it "should be able to cache a subtitle" do
|
175
|
+
torrent = create_torrent
|
176
|
+
torrent.should_receive(:imdb_id).any_number_of_times.times.and_return("tt0990407")
|
177
|
+
torrent.should_receive(:title).any_number_of_times.and_return("a subtitle")
|
178
|
+
Undertexter.should_receive(:find).with("tt0990407", language: :swedish).exactly(1).times.and_return([Struct.new(:title).new("a subtitle")])
|
179
|
+
Undertexter.should_receive(:find).with("tt0990407", language: :english).exactly(1).times.and_return([Struct.new(:title).new("a subtitle")])
|
180
|
+
|
181
|
+
10.times { torrent.subtitle(:swedish).title.should eq("a subtitle") }
|
182
|
+
10.times { torrent.subtitle(:english).title.should eq("a subtitle") }
|
183
|
+
end
|
173
184
|
end
|
174
185
|
|
175
186
|
|
data/torrents.gemspec
CHANGED