Sha256: 47c987cf76b418e9e80e3257800ad0116efe4ed7d43497f980bc48a3854cb19c

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

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

describe Bremen::Nicovideo do
  describe '.find_url' do
    subject{ Bremen::Nicovideo.find_url(uid_or_url) }
    describe 'given id' do
      let(:uid_or_url){ 'sm1111111' }
      it 'generate' do
        subject.must_equal 'http://www.nicovideo.jp/watch/sm1111111'
      end
    end

    describe 'given url' do
      let(:uid_or_url){ 'http://www.nicovideo.jp/watch/sm1111111' }
      it 'generate' do
        subject.must_equal 'http://www.nicovideo.jp/watch/sm1111111'
      end
    end
  end

  describe '.search_url' do
    subject{ Bremen::Nicovideo.search_url(params) }
    describe 'only keyword' do
      let(:params){ {keyword: 'searchword'} }
      it 'generate' do
        subject.must_equal 'http://www.nicovideo.jp/search/searchword?sort=f&order=d&f_range=&l_range=&opt_md='
      end
    end

    describe 'full params' do
      let(:params){ {keyword: 'searchword', sort: 'n', order: 'a', within: 3, length: 2, downloadable: 1} }
      it 'generate' do
        subject.must_equal 'http://www.nicovideo.jp/search/searchword?sort=n&order=a&f_range=3&l_range=2&opt_md=1'
      end
    end
  end

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

  describe '.convert_multiply' do
    subject{ Bremen::Nicovideo.send(:convert_multiply, response) }
    let(:response){ fixture('nicovideo_multi.html') }
    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/nicovideo_spec.rb
bremen-0.1.1 spec/bremen/nicovideo_spec.rb
bremen-0.1.0 spec/bremen/nicovideo_spec.rb