lc_api 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ module LcApi
15
15
  private
16
16
 
17
17
  def find_format(name)
18
- (self.formats.select {|f| f.name.downcase.gsub(/\s+/, "_") == name.to_s.downcase}).first
18
+ (self.formats.detect {|f| f.name.downcase.gsub(/\s+/, "_") == name.to_s.downcase})
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,9 @@
1
1
  module LcApi
2
2
  class Series < Base
3
3
  has_many :messages, :class_name => "LcApi::Message"
4
+
5
+ def find_image(name)
6
+ (self.images.detect {|f| f.name.downcase == name.to_s.downcase})
7
+ end
4
8
  end
5
9
  end
@@ -1,3 +1,3 @@
1
1
  module LcApi
2
- VERSION = "1.2"
2
+ VERSION = "1.3"
3
3
  end
@@ -9,7 +9,7 @@ describe LcApi::Series do
9
9
  end
10
10
  end
11
11
 
12
- describe "returning a single series" do
12
+ describe "returning a single series by id" do
13
13
  it "should return a series" do
14
14
  FakeWeb.register_uri(:get, "#{SITE_URL}/series/2.json?key=1111", :body => fixture("series.json"))
15
15
  @series = LcApi::Series.find(2)
@@ -17,6 +17,14 @@ describe LcApi::Series do
17
17
  end
18
18
  end
19
19
 
20
+ describe "returning a single series by slug" do
21
+ it "should return a series" do
22
+ FakeWeb.register_uri(:get, "#{SITE_URL}/series/series-slug-example.json?key=1111", :body => fixture("series.json"))
23
+ @series = LcApi::Series.find("series-slug-example")
24
+ expect(@series.class).to eq LcApi::Series
25
+ end
26
+ end
27
+
20
28
  describe "including the messages info" do
21
29
  it "should include 'messages' in the url" do
22
30
  # If this test passes, that means the url below was correctly called, no need for any expects
@@ -42,4 +50,14 @@ describe LcApi::Series do
42
50
  end
43
51
  end
44
52
  end
53
+
54
+ describe "finding different images" do
55
+ describe ".find_image" do
56
+ it "should find the image" do
57
+ FakeWeb.register_uri(:get, "#{SITE_URL}/series/2.json?key=1111", :body => fixture("series.json"))
58
+ series = LcApi::Series.find(2)
59
+ expect(series.find_image("224x160").url).to eq "http://s3.amazonaws.com/lcapi.production/series/small-things/224x160.jpg?1391467308"
60
+ end
61
+ end
62
+ end
45
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lc_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-07 00:00:00.000000000 Z
12
+ date: 2014-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource