Sha256: a3afcc0d52797b3780ea5794288f0dae38ddbc8af64f5d0fc3c3b9ff36cfa415

Contents?: true

Size: 1.02 KB

Versions: 33

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe 'Lastfm::Response' do
  before do
    @ok = open(fixture('ok.xml')).read
    @ng = open(fixture('ng.xml')).read
  end

  describe '.new' do
    it 'should instantiate' do
      Lastfm::Response.new(@ok).should be_an_instance_of(Lastfm::Response)
    end
  end

  describe 'success' do
    before do
      @response = Lastfm::Response.new(@ok)
    end

    it 'should be success' do
      @response.should be_success
    end

    it 'should parse response body as xml' do
      xml = @response.xml
      xml['similartracks']['track'].size.should == 7
    end
  end

  describe 'failure' do
    before do
      @response = Lastfm::Response.new(@ng)
    end

    it 'should not be success' do
      @response.should_not be_success
    end

    it 'should have message' do
      @response.message.should == 'Invalid API key - You must be granted a valid key by last.fm'
    end

    it 'should have error number' do
      @response.error.should == 10
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
lastfm-1.27.3 spec/response_spec.rb
lastfm-1.27.2 spec/response_spec.rb
lastfm-1.27.1 spec/response_spec.rb
lastfm-1.27.0 spec/response_spec.rb
lastfm-1.26.0 spec/response_spec.rb
lastfm-1.25.0 spec/response_spec.rb
lastfm-1.24.0 spec/response_spec.rb
lastfm-1.23.0 spec/response_spec.rb
lastfm-1.22.0 spec/response_spec.rb
lastfm-1.21.0 spec/response_spec.rb
lastfm-1.20.1 spec/response_spec.rb
lastfm-1.19.1 spec/response_spec.rb
lastfm-1.19.0 spec/response_spec.rb
lastfm-1.18.0 spec/response_spec.rb
lastfm-1.17.0 spec/response_spec.rb
lastfm-1.16.0 spec/response_spec.rb
lastfm-1.15.1 spec/response_spec.rb
lastfm-1.15.0 spec/response_spec.rb
lastfm-1.14.1 spec/response_spec.rb
lastfm-1.14.0 spec/response_spec.rb