Sha256: 30e4434397d4c44b73a5b76c4a3427443329bebf60393d4d4f0fbe0148b33e61

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"
require "./lib/spot/song"

describe SpotContainer::Song do
  before(:each) do
    @song = SpotContainer::Song.new(JSON.load(File.read("spec/fixtures/track.json"))["tracks"].first)
  end
  
  context "the available? method" do
    it "should contain the AM territory" do
      @song.should be_available("AM")
    end
    
    it "should not contain the RANDOM territory" do
      @song.should_not be_available("RANDOM")
    end
  end
  
  it "should have an artist" do
    @song.artist.should be_instance_of(SpotContainer::Artist)
  end
  
  it "should have an album" do
    @song.album.should be_instance_of(SpotContainer::Album)
  end
  
  it "should have the correct accessors" do
    @song.length.should be_instance_of(Float)
  end
  
  context "the valid? method" do
    it "should not be valid due to the non existing territory" do
      @song.territory = "RANDOM"
      @song.should_not be_valid
    end
    
    it "should not be valid due to the non existing territory" do
      @song.territory = "AM"
      @song.should be_valid
    end
    
    it "should be valid if no territory if passed" do
      @song.should be_valid
    end
  end
  
  it "should inherit from base" do
    @song.class.ancestors.should include(SpotContainer::Base)
  end
  
  it "should have a title method that equals the name method" do
    @song.title.should eq(@song.name)
  end
  
  it "should have a working to string method" do
    @song.to_s.should eq("#{@song.title} - #{@song.artist.name}")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spot-0.1.3 spec/song_spec.rb
spot-0.1.2 spec/song_spec.rb
spot-0.1.1 spec/song_spec.rb