Sha256: 89e457d92a4a6f2271caafd1abffaf3bfd3bd660623b300f634cfd48fe1e4f97

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"
require "./lib/spot/base"

describe SpotContainer::Base do
  before(:each) do
    @base = SpotContainer::Base.new(JSON.load(File.read("spec/fixtures/track.json"))["tracks"].first)
  end
  
  it "should have the correct accessors" do
    @base.name.should_not be_empty
    @base.popularity.should eq(0.79999)
    @base.href.should match(/^spotify\:\w+\:[a-zA-Z0-9]+$/)
  end
  
  context "the url methods" do
    it "should have a default type" do
      @base.href.should eq("spotify:track:7lqGgwrEhURX4k5IB8A80S")
    end
    
    it "should be possible to define a url href" do
      @base.href("spotify").should eq("spotify:track:7lqGgwrEhURX4k5IB8A80S")
    end
    
    it "should be possible to define a http href" do
      @base.href("http").should eq("http://open.spotify.com/track/7lqGgwrEhURX4k5IB8A80S")
    end
    
    it "should return nil if no URL if found" do
      @base.should_receive(:href_spotify).exactly(3).times.and_return(nil)
      @base.href("spotify").should be_nil
      @base.href("http").should be_nil
      @base.href.should be_nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spot-0.1.4 spec/base_spec.rb
spot-0.1.3 spec/base_spec.rb
spot-0.1.2 spec/base_spec.rb
spot-0.1.1 spec/base_spec.rb