# encoding: utf-8 require 'spec_helper' describe "./bin/quandl delete" do let(:command){ self.class.superclass.description } subject{ quandl("delete #{command}") } context "DOES_NOT_EXIST" do its(:stdout){ should match 'Not Found' } end context "DATASET_1" do before(:each){ create(:dataset, code: 'DATASET_1') } its(:stdout){ should match 'Deleted' } end end 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 Spec::Config::Output.should_receive(:info).with(/Deleted/).at_least(4).times datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf') datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) } end it "should not download" do datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf') datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) } Spec::Config::Output.should_receive(:info).with(nil).at_least(4).times datasets.each{|d| Quandl::Command::Tasks::Download.call( d.code ) } end end end