Sha256: a106729d86b1467f1e1b6beaf92e1ae6921f209b01b4e7724cb1a1999300dd27

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

describe Hallon::Toplist do
  subject do
    mock_session do
      Spotify.should_receive(:toplistbrowse_create).and_return(mock_toplistbrowse)
      Hallon::Toplist.new(:artists)
    end
  end

  it { should be_a Hallon::Observable }
  it { should be_loaded }
  its(:error) { should eq :ok }

  its('artists.size') { should eq 2 }
  its('artists.to_a') { should eq instantiate(Hallon::Artist, mock_artist, mock_artist_two) }

  its('albums.size') { should eq 1 }
  its('albums.to_a') { should eq instantiate(Hallon::Album, mock_album) }

  its('tracks.size') { should eq 2 }
  its('tracks.to_a') { should eq instantiate(Hallon::Track, mock_track, mock_track_two) }

  describe ".new" do
    around { |test| mock_session(&test) }

    it "should fail given an invalid type" do
      expect { Hallon::Toplist.new(:invalid_type) }.to raise_error(ArgumentError, /invalid enum value/)
    end

    it "should pass the username given a string to libspotify" do
      Spotify.should_receive(:toplistbrowse_create).with(anything, anything, :user, "Kim", anything, nil).and_return(null_pointer)
      Hallon::Toplist.new(:artists, "Kim")
    end

    it "should pass the correct region to libspotify" do
      sweden = 21317
      Spotify.should_receive(:toplistbrowse_create).with(anything, anything, sweden, anything, anything, nil).and_return(null_pointer)
      Hallon::Toplist.new(:artists, :se)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hallon-0.8.0 spec/hallon/toplist_spec.rb