Sha256: 6bc506f549a9e85f6f97c341cf22d0f513220fcf35d3c0e208e3d10ba79afff3

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

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

set :environment, :test

require 'nokogiri'

describe Rack::MusicIndex do
  def app
    Sinatra::Application
  end

  it 'should index mp3s as podcast' do
    get '/foo'

    last_response.should be_ok

    xml = Nokogiri::XML(last_response.body)

    channel = xml.xpath('//channel')[0]
    items = xml.xpath('//item')
    item = items[0]

    channel.xpath('title')[0].content.should eql('/foo')
    channel.xpath('description')[0].content.should eql('Generated by Rack::MusicIndex')

    items.size.should eql(1)
    item.xpath('title')[0].content.should eql('test.mp3')
    item.xpath('link')[0].content.should eql('http://example.org/foo/test.mp3')
    item.xpath('guid')[0].content.should eql('http://example.org/foo/test.mp3')
    item.xpath('enclosure')[0]['url'].should eql('http://example.org/foo/test.mp3')
  end

  it 'should return mp3' do
    get '/foo/test.mp3'

    last_response.should be_ok
    last_response['Content-Type'].should eql('audio/mpeg')
    last_response.body.should eql(open(fixture('/foo/test.mp3')).read)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-musicindex-0.0.1 spec/rack/musicindex_spec.rb