require 'spec_helper' describe JamTrackImporter do let(:s3_manager) { S3Manager.new(app_config.aws_bucket_jamtracks, app_config.aws_access_key_id, app_config.aws_secret_access_key) } let(:sample_yml) { { "name" => "Back in Black", "plan_code" => "jamtrack-acdc-backinblack", "recording_type" => 'Cover', "pro" => 'ASCAP', "genre" => 'rock' } } describe "load_metalocation" do include UsesTempFiles metafile = 'meta.yml' in_directory_with_file(metafile) before(:each) do content_for_file(YAML.dump(sample_yml)) end it "no meta" do s3_metalocation = 'audio/Artist 1/Bogus Place/meta.yml' JamTrackImporter.load_metalocation(s3_metalocation).should be_nil end it "successfully" do s3_metalocation = 'audio/Artist 1/Song 1/meta.yml' s3_manager.upload(s3_metalocation, metafile) JamTrackImporter.load_metalocation(s3_metalocation).should eq(sample_yml) end end describe "synchronize" do let(:jam_track) { JamTrack.new } let(:importer) { JamTrackImporter.new } let(:minimum_meta) { nil } let(:metalocation) { 'audio/Artist 1/Song 1/meta.yml' } let(:options) {{ skip_audio_upload:true }} it "bare minimum specification" do importer.synchronize_metadata(jam_track, minimum_meta, metalocation, 'Artist 1', 'Song 1') jam_track.plan_code.should eq('jamtrack-artist1-song1') jam_track.name.should eq("Song 1") jam_track.description.should == "This is a JamTrack audio file for use exclusively with the JamKazam service. This JamTrack is a high quality cover of the Artist 1 song \"Song 1\"." jam_track.time_signature.should be_nil jam_track.status.should eq('Staging') jam_track.recording_type.should eq('Cover') jam_track.original_artist.should eq('Artist 1') jam_track.songwriter.should be_nil jam_track.publisher.should be_nil jam_track.sales_region.should eq('United States') jam_track.price.should eq(1.99) end end describe "parse_wav" do it "Guitar" do result = JamTrackImporter.new.parse_wav('blah/Ready for Love Stem - Guitar - Main.wav') result[:instrument].should eq('electric guitar') result[:part].should eq('Main') end end end