Sha256: 2c3c0347ba0634e6ea6499ceb0d5f1f71a59e7443b92326e72133f78b804a271

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe "Soundcloud::Models::User" do 
  before(:all) do
    @sc = Soundcloud.register({:access_token=> valid_oauth_access_token, :site => soundcloud_site})

    @api_test_1 = @sc.User.find('api-test-1')    
    @api_test_2 = @sc.User.find('api-test-2')    
    @api_test_3 = @sc.User.find('api-test-3')  
    # TODO do the  before(:something)
    begin
      #remove, just in case it's a contact already
      @api_test_3.remove_contact!
    rescue
      #ignore
    end
  end
  
  it 'should find a user with a specific name' do
    test_for = 'api-test-2'
    user = @sc.User.find(test_for)
    user.username.should == test_for
  end
  
  it 'should find all api-test users' do
    test_for = 'api-test'
    users = @sc.User.find(:all , :params => {:q => test_for})
    users.count.should be >= 3
  end
  
  it 'should check if a user has a contact' do 
    @api_test_2.has_contact?(@api_test_3).should be true
    @api_test_2.has_contact?(@api_test_3.id).should be true    
    @api_test_3.has_contact?(@api_test_1).should be false
  end
  
  it 'should add, check and remove a contact' do
    @api_test_3.is_contact?.should be false
    @api_test_3.add_contact!
    @api_test_3.is_contact?.should be true
    @api_test_3.remove_contact!    
  end

  it 'should check if a user has a favorite' do
    track1 = @sc.Track.find('track1-2')
    track2 = @sc.Track.find('track2-2')
    @api_test_2.has_favorite?(track1).should be true
    @api_test_2.has_favorite?(track1.id).should be true    
    @api_test_2.has_favorite?(track2).should be false
  end      
  
  it 'should find the logged in user' do 
    my_user = @sc.User.find_me
    my_user.username.should_not be nil
  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soundcloud-ruby-api-wrapper-0.1.5 spec/soundcloud_user_spec.rb