Files
old-holivud2/spec/models/audio_confirmation_spec.rb
2020-05-31 22:38:19 +02:00

56 lines
2.0 KiB
Ruby

require "rails_helper"
RSpec.describe AudioConfirmation do
describe "associations" do
it { is_expected.to belong_to(:video) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:time_elapsed) }
describe "confirmation_type" do
it "validates only original_music and library_music are allowed" do
expect(build(:audio_confirmation, confirmation_type: "original_music").valid?).to eq true
expect(build(:audio_confirmation, confirmation_type: "library_music").valid?).to eq true
expect(build(:audio_confirmation, confirmation_type: "unknown_music").valid?).to eq false
end
end
end
describe "#appears_at" do
it "returns formatted timecode" do
audio_confirmation = build(:audio_confirmation, time_elapsed: "1.039")
expect(audio_confirmation.appears_at).to eq "00:00:01:01"
end
end
describe "#presented_source_file_name" do
context "when confirmation_type is original_music" do
it "returns source_file_name with (O) prefix" do
audio_confirmation = build(:audio_confirmation, confirmation_type: "original_music", source_file_name: "source_file_name")
expect(audio_confirmation.presented_source_file_name).to eq "(O) source_file_name"
end
end
context "when confirmation_type is library_music" do
it "returns source_file_name with (L) prefix" do
audio_confirmation = build(:audio_confirmation, confirmation_type: "library_music", source_file_name: "source_file_name")
expect(audio_confirmation.presented_source_file_name).to eq "(L) source_file_name"
end
end
end
describe "#confirmation_type_library?" do
it "returns true when confirmation_type is library" do
expect(build(:audio_confirmation, :library)).to be_confirmation_type_library
end
it "returns false when confirmation_type is not library" do
expect(build(:audio_confirmation, :original)).not_to be_confirmation_type_library
end
end
end