This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Handle empty playback

  • Loading branch information...
pengwynn committed Dec 30, 2012
1 parent f6ca46d commit a5fdb4e52de0f1f23b1263a778f512aee7e39079
Showing with 11 additions and 3 deletions.
  1. +2 −0 lib/rdio/desktop_bridge.rb
  2. +9 −3 spec/rdio/desktop_bridge_spec.rb
@@ -47,6 +47,8 @@ def current_album
end
def now_playing(text=nil)
+ return "Nothing playing" if current_track.empty?
+
text ||= "Now playing: %{track} / %{artist} / %{album}"
text % {
:artist => current_artist,
@@ -93,17 +93,23 @@
context "displaying now playing info" do
- before do
+ it "displays track, artist, and album by default" do
@bridge.stub(:current_track).and_return("Hurt")
@bridge.stub(:current_artist).and_return("Johnny Cash")
@bridge.stub(:current_album).and_return("The Man Comes Around")
- end
- it "displays track, artist, and album by default" do
expect(@bridge.now_playing).to \
eq("Now playing: Hurt / Johnny Cash / The Man Comes Around")
end
+ it "handles nothing playing" do
+ @bridge.stub(:current_track).and_return('')
+ @bridge.stub(:current_artist).and_return('')
+ @bridge.stub(:current_album).and_return('')
+
+ expect(@bridge.now_playing).to eq("Nothing playing")
+ end
+
end
context "URLs" do

0 comments on commit a5fdb4e

Please sign in to comment.