bandcamp_api 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,23 @@
1
+ require 'bandcamp/track'
2
+ require 'bandcamp/associated'
1
3
  require 'bandcamp/methodical'
2
4
 
3
5
  module Bandcamp
4
6
  class Album
5
7
 
6
8
  include Methodical
9
+ include Associated
7
10
 
8
11
  def initialize album_hash
9
12
  to_methods album_hash
13
+ if instance_variable_defined? "@tracks"
14
+ @tracks = @tracks.map{|track| Track.new(track)}
15
+ end
10
16
  end
11
17
 
18
+ def band
19
+ retrieve_associated :band
20
+ end
12
21
 
13
22
  end
14
23
  end
@@ -1,3 +1,3 @@
1
1
  module Bandcamp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/album_spec.rb CHANGED
@@ -1,16 +1,44 @@
1
+ require 'multi_json'
2
+ require 'bandcamp/band'
1
3
  require 'bandcamp/album'
2
4
 
3
5
  module Bandcamp
4
6
  describe Album do
7
+
8
+ let(:album_hash){ MultiJson.decode File.read(File.join %w(spec fixtures remixes_and_rarities_album.json)) }
9
+ let(:album){ Album.new(album_hash) }
10
+
11
+ it "includes the Associated Module" do
12
+ expect(album.private_methods).to include :retrieve_associated
13
+ end
14
+
15
+ it "includes the Methodical module" do
16
+ expect(album.private_methods).to include :to_methods
17
+ end
18
+
5
19
  describe ".new" do
6
20
 
7
21
  it "accepts a hash and returns an Album" do
8
- expect(Album.new(foo: "bar")).to be_an Album
22
+ expect(album).to be_an Album
9
23
  end
10
24
 
11
25
  it "creates methods based on the hash" do
12
26
  expect(Album.new(foo: "bar").foo).to eq "bar"
13
27
  end
14
28
  end
29
+
30
+ describe "#band" do
31
+ it "returns the associated band" do
32
+ album.stub(:retrieve_associated).and_return(Band.new(band_id: 123456789))
33
+ expect(album.band).to be_a Band
34
+ end
35
+ end
36
+
37
+ describe "#tracks" do
38
+ it "returns an array of Track objects" do
39
+ expect(album.tracks.first).to be_a Track
40
+ end
41
+ end
42
+
15
43
  end
16
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandcamp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
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: 2013-01-25 00:00:00.000000000 Z
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec