Sha256: b2a0bbe8e7393525045f5b4f5332ff8ecce190aa7d32e7b7ab4a24641b8cf61d

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

$:.unshift(File.expand_path('../../', __FILE__))
require 'spec_helper'

describe Bremen::Mixcloud do
  describe '.find_url' do
    subject{ Bremen::Mixcloud.find_url(uid_or_url) }
    describe 'given id' do
      let(:uid_or_url){ '/author/permalink/' }
      it 'generate' do
        subject.must_equal 'http://api.mixcloud.com/author/permalink/'
      end
    end

    describe 'given url' do
      let(:uid_or_url){ 'http://www.mixcloud.com/author/permalink/' }
      it 'generate' do
        subject.must_equal 'http://api.mixcloud.com/author/permalink/'
      end
    end
  end

  describe '.search_url' do
    subject{ Bremen::Mixcloud.search_url(params) }
    describe 'only keyword' do
      let(:params){ {keyword: 'searchword'} }
      it 'generate' do
        subject.must_equal 'http://api.mixcloud.com/search/?q=searchword&limit=20&type=cloudcast'
      end
    end

    describe 'full params' do
      let(:params){ {keyword: 'searchword', limit: 1} }
      it 'generate' do
        subject.must_equal 'http://api.mixcloud.com/search/?q=searchword&limit=1&type=cloudcast'
      end
    end
  end

  describe '.convert_singly' do
    subject{ Bremen::Mixcloud.send(:convert_singly, response) }
    let(:response){ fixture('mixcloud_single.json') }
    it 'convert successfully' do
      subject.title.must_equal 'Title'
    end
  end

  describe '.convert_multiply' do
    subject{ Bremen::Mixcloud.send(:convert_multiply, response) }
    let(:response){ fixture('mixcloud_multi.json') }
    it 'convert successfully' do
      subject.first.title.must_equal 'Title'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bremen-0.1.2 spec/bremen/mixcloud_spec.rb
bremen-0.1.1 spec/bremen/mixcloud_spec.rb
bremen-0.1.0 spec/bremen/mixcloud_spec.rb