Sha256: fa2f94fecb488c4b6081734b1b78a3dd343f72d162d4032be085aa424a3ef00a

Contents?: true

Size: 1.63 KB

Versions: 20

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Kagu::Playlist do

  let(:library) { Kagu::Library.new }
  let(:playlist) { Kagu::Playlist.new(name: 'Best tracks', tracks: tracks) }
  let(:tracks) { library.tracks.take(15) }

  describe '#each' do

    it 'is delegated to tracks' do
      track = nil
      playlist.each do |t|
        track = t
        break
      end
      expect(track).to be_a(Kagu::Track)
    end

  end

  describe '#itunes_name=' do

    it 'set name and convert entities' do
      expect {
        playlist.send(:itunes_name=, 'Hello & World')
      }.to change { playlist.name }.from('Best tracks').to('Hello & World')
    end

  end

  describe '#name' do

    it 'is set at initialization' do
      expect(Kagu::Playlist.new(name: 'Best tracks').name).to eq('Best tracks')
    end

    it 'is squished' do
      expect(Kagu::Playlist.new(name: "Best  \t tracks\n").name).to eq('Best tracks')
    end

    it 'is mandatory' do
      expect {
        Kagu::Playlist.new(name: ' ')
      }.to raise_error(Kagu::Error, 'Kagu::Playlist#name is mandatory')
    end

  end

  describe '#to_s' do

    it 'is name' do
      expect(Kagu::Playlist.new(name: 'Best tracks').to_s).to eq('Best tracks')
    end

  end

  describe '#tracks' do

    it 'is an empty array by default' do
      expect(Kagu::Playlist.new(name: 'Test').tracks).to eq([])
    end

    it 'is tracks given at initialization' do
      expect(Kagu::Playlist.new(name: 'Test', tracks: tracks).tracks).to eq(tracks)
    end

    it 'removes invalid tracks' do
      expect(Kagu::Playlist.new(name: 'Test', tracks: ['bar', [tracks.first], 'foo']).tracks).to eq([tracks.first])
    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
kagu-1.2.0 spec/kagu/playlist_spec.rb
kagu-1.1.2 spec/kagu/playlist_spec.rb
kagu-1.1.1 spec/kagu/playlist_spec.rb
kagu-1.1.0 spec/kagu/playlist_spec.rb
kagu-1.0.0 spec/kagu/playlist_spec.rb
kagu-0.4.7 spec/kagu/playlist_spec.rb
kagu-0.4.6 spec/kagu/playlist_spec.rb
kagu-0.4.5 spec/kagu/playlist_spec.rb
kagu-0.4.4 spec/kagu/playlist_spec.rb
kagu-0.4.3 spec/kagu/playlist_spec.rb
kagu-0.4.2 spec/kagu/playlist_spec.rb
kagu-0.4.1 spec/kagu/playlist_spec.rb
kagu-0.4.0 spec/kagu/playlist_spec.rb
kagu-0.3.3 spec/kagu/playlist_spec.rb
kagu-0.3.2 spec/kagu/playlist_spec.rb
kagu-0.3.1 spec/kagu/playlist_spec.rb
kagu-0.3.0 spec/kagu/playlist_spec.rb
kagu-0.2.4 spec/kagu/playlist_spec.rb
kagu-0.2.3 spec/kagu/playlist_spec.rb
kagu-0.2.2 spec/kagu/playlist_spec.rb