spec/hallon/album_spec.rb in hallon-0.15.0 vs spec/hallon/album_spec.rb in hallon-0.16.0
- old
+ new
@@ -1,59 +1,94 @@
# coding: utf-8
#
describe Hallon::Album do
- it { should be_a Hallon::Loadable }
+ let(:album) do
+ Hallon::Album.new(mock_albums[:default])
+ end
+ let(:empty_album) do
+ Hallon::Album.new(mock_albums[:empty])
+ end
+
+ specify { album.should be_a Hallon::Loadable }
+
it_should_behave_like "a Linkable object" do
let(:spotify_uri) { "spotify:album:1xvnWMz2PNFf7mXOSRuLws" }
end
- let(:album) { Hallon::Album.new(mock_album) }
- subject { album }
+ describe ".types" do
+ subject { Hallon::Album.types }
- its(:name) { should eq "Finally Woken" }
- its(:release_year) { should be 2004 }
- its(:type) { should be :single }
- its(:browse) do
- mock_session { should eq Hallon::AlbumBrowse.new(album) }
+ it { should be_an Array }
+ it { should include :single }
end
- it { should be_available }
- it { should be_loaded }
+ describe "#name" do
+ it "returns the album’s name" do
+ album.name.should eq "Finally Woken"
+ end
- describe "artist" do
- it "should be nil if there is no artist" do
- Spotify.should_receive(:album_artist).and_return(null_pointer)
- album.artist.should be_nil
+ it "returns an empty string if the album is not loaded" do
+ empty_album.name.should be_empty
end
+ end
+ describe "#release_year" do
+ it "returns the album’s release year" do
+ album.release_year.should eq 2004
+ end
+ end
+
+ describe "#type" do
+ it "returns the album’s type" do
+ album.type.should eq :single
+ end
+ end
+
+ describe "#browse" do
+ it "returns the album’s browser object" do
+ album.browse.should eq Hallon::AlbumBrowse.new(album)
+ end
+ end
+
+ describe "#available?" do
+ it "returns true when the album is available" do
+ album.should be_available
+ end
+ end
+
+ describe "#loaded?" do
+ it "returns true when the album is loaded" do
+ album.should be_loaded
+ end
+ end
+
+ describe "artist" do
it "should be an artist if it exists" do
album.artist.should eq Hallon::Artist.new(mock_artist)
end
- end
- describe "#cover" do
- it "should be nil if there is no image" do
- Spotify.should_receive(:album_cover).and_return(null_pointer)
- album.cover.should be_nil
+ it "should be nil if there is no artist" do
+ empty_album.artist.should be_nil
end
+ end
+ describe "#cover" do
it "should be an image if it exists" do
- stub_session { album.cover.should eq Hallon::Image.new(mock_image_id) }
+ album.cover.should eq Hallon::Image.new(mock_image_id)
end
- end
- describe "#cover_link" do
it "should be nil if there is no image" do
- Spotify.should_receive(:link_create_from_album_cover).and_return(null_pointer)
- album.cover_link.should be_nil
+ empty_album.cover.should be_nil
end
+ end
+ describe "#cover_link" do
it "should be a link if it exists" do
album.cover_link.should eq Hallon::Link.new("spotify:image:3ad93423add99766e02d563605c6e76ed2b0e400")
end
- end
- describe ".types" do
- specify { Hallon::Album.types.should_not be_empty }
+ it "should be nil if there is no image" do
+ empty_album.cover_link.should be_nil
+ end
end
end