public
Description: Scrobbler is a wrapper for the audioscrobbler (last.fm) web services.
Homepage: http://scrobbler.rubyforge.org/
Clone URL: git://github.com/jnunemaker/scrobbler.git
Click here to lend your support to: scrobbler and make a donation at www.pledgie.com !
scrobbler / test / unit / track_test.rb
100644 42 lines (34 sloc) 1.399 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require File.dirname(__FILE__) + '/../test_helper.rb'
 
class TestTrack < Test::Unit::TestCase
  def setup
    @track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
  end
  
  test 'should require the artist name' do
    assert_raises(ArgumentError) { Scrobbler::Track.new('', 'Before He Cheats') }
  end
  
  test 'should require the track name' do
    assert_raises(ArgumentError) { Scrobbler::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 api path' do
    assert_equal('/1.0/track/Carrie+Underwood/Before+He+Cheats', @track.api_path)
  end
  
  test 'should have fans' do
    assert_equal(5, @track.fans.size)
    assert_equal('frozenice', @track.fans.first.username)
    assert_equal('http://www.last.fm/user/frozenice/', @track.fans.first.url)
    assert_equal('http://panther1.last.fm/avatar/54e8d2cafc363336e15fef0a48d30706.jpg', @track.fans.first.avatar)
    assert_equal('909', @track.fans.first.weight)
  end
  
  test 'should have top tags' do
    assert_equal(6, @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
end