aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/record_spec.rb
blob: 9634a764d8ba104b5b454e21b14ae8d1b86974d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (C) 2014 Harald Eilertsen
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 'test_helper'

describe SeventyEights::Record do
  describe "when creating a record" do
    before do
      @r = SeventyEights::Record.new("BamBam", "The Strokes", "Virginia Records", "VR666-1", URI.parse('http://example.com/test.mp3'))
    end

    it "must have the correct title" do
      @r.title.must_equal "BamBam"
    end

    it "must have correct artist" do
      @r.artist.must_equal "The Strokes"
    end

    it "must have correct label" do
      @r.label.must_equal "Virginia Records"
    end

    it "must have correct catalog number" do
      @r.catalog.must_equal "VR666-1"
    end

    it "must have correct URL" do
      @r.url.to_s.must_equal 'http://example.com/test.mp3'
    end

    it "must generate a sensible filename" do
      @r.to_filename.must_equal 'BamBam - The Strokes - Virginia Records - VR666-1.mp3'
    end
  end

  describe "a record with slashes in a field" do
    before do
      @r = SeventyEights::Record.new("BamBam", "The Strokes w/Bunny Boo", "Virginia Records", "VR666-1", URI.parse('http://example.com/test.mp3'))
    end

    it "must create a valid filename" do
      @r.to_filename.must_equal 'BamBam - The Strokes w-Bunny Boo - Virginia Records - VR666-1.mp3'
    end
  end
end