Sha256: cd989252ff7abf5d24b9c349e966df79086097b3fde42c52da072272f57459d0

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require File.expand_path('../../test_helper.rb', __FILE__)

class TestTrack < Test::Unit::TestCase

  def setup
    @track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
  end
  
  test 'should require the artist name' do
    assert_raises(ArgumentError) { Rockstar::Track.new('', 'Before He Cheats') }
  end
  
  test 'should require the track name' do
    assert_raises(ArgumentError) { Rockstar::Track.new('Carrie Underwood', '') }
  end
  
  test "should know the artist" do
    assert_equal('Carrie Underwood', @track.artist)
  end
  
  test 'should know the name' do
    assert_equal('Before He Cheats', @track.name)
  end
  
  test 'should have fans' do
    assert_equal(50, @track.fans.size)
    assert_equal('chelseaf89', @track.fans.first.username)
    assert_equal('http://www.last.fm/user/chelseaf89', @track.fans.first.url)
    assert_equal('http://userserve-ak.last.fm/serve/34/41303325.jpg', @track.fans.first.avatar)
    assert_equal('5000000', @track.fans.first.weight)
  end
  
  test 'should have top tags' do
    assert_equal(100, @track.tags.size)
    assert_equal('country', @track.tags.first.name)
    assert_equal('100', @track.tags.first.count)
    assert_equal('http://www.last.fm/tag/country', @track.tags.first.url)
  end
  
  test 'can love tracks' do
    assert_equal('ok', @track.love("tag"))  
  end

  test 'raise missing parameter error in scrobble' do
    assert_raises(ArgumentError) { Rockstar::Track.scrobble() }
  end

  test 'can scrobble tracks' do
    assert_equal('ok', @track.scrobble(Time.new(2010,10,10,10,10), 'tag'))
  end

  test 'raise missing parameter error in update now playing' do
    assert_raises(ArgumentError) { Rockstar::Track.updateNowPlaying() }
  end

  test 'can send current playing track' do
    assert_equal('ok', @track.updateNowPlaying(Time.new(2010,10,10,10,10), 'tag'))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rockstar-0.5.1 test/unit/test_track.rb