Sha256: f2d36260b7b87c035b743ba785e76f73d499d66fd6a8bbcfb2cf159423f8b58b

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

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

describe "Lastfm::Response" do
  describe '.new' do
    it 'should instantiate' do
      Lastfm::Response.new('{ "foo": "bar" }').should be_an_instance_of(Lastfm::Response)
    end
  end

  describe 'success' do
    before do
      @response = Lastfm::Response.new('{ "foo": "bar" }')
    end

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

    it 'should parse response body as json' do
      @response['foo'].should eql('bar')
    end

    it 'should ignore unexpected xml response' do
       Lastfm::Response.new('<?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
</lfm>
').should be_success
     end
  end

  describe 'failure' do
    before do
      @response = Lastfm::Response.new('{"message": "Invalid Method - No method with that name in this package", "error": 3}')
    end

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

    it 'should have message' do
      @response.message.should eql('Invalid Method - No method with that name in this package')
    end

    it 'should have error number' do
      @response.error.should eql(3)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
claudiob-lastfm-0.0.1 spec/response_spec.rb
lastfm-0.0.1 spec/response_spec.rb