# encoding: utf-8 require 'spec_helper' describe Quandl::Command::Tasks::Delete do let(:subject_args){ [] } subject{ Quandl::Command::Tasks::Delete.call(*subject_args) } context "spec/fixtures/data/datasets.qdf" do before(:each){ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' ) } it "should delete spec/fixtures/data/datasets.qdf" do Quandl::Logger.should_receive(:info).with(/Deleted/).exactly(4).times # load each dataset from file datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf') # send command to delete each dataset datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) } Quandl::Logger.should_receive(:error).with(/Not Found/).exactly(4).times datasets.each{|d| Quandl::Command::Tasks::Download.call( d.code ) } end end it "should fail to delete missing dataset" do Quandl::Logger.should_receive(:error).with(/Not Found/).exactly(1).times Quandl::Command::Tasks::Delete.call("DOES_NOT_EXIST", force_yes: true ) end end