Sha256: 8f77f5f697b04ca5dd97cdb7aea6c8286f03ce751fd7475a815dbecd27cbeba9
Contents?: true
Size: 1.87 KB
Versions: 14
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' describe Heirloom do before do @logger_mock = mock 'logger' @logger_mock.stub :info => true, :debug => true @config_mock = mock 'config' @config_mock.stub :logger => @logger_mock @tempfile_stub = stub 'tempfile', :path => '/tmp/tempfile' Tempfile.stub :new => @tempfile_stub @writer = Heirloom::Writer.new :config => @config_mock end context "extract is set to true" do it "should extract the given archive object into the output directory" do File.should_receive(:open).with('/tmp/tempfile', 'w') Heirloom::Writer.any_instance.should_receive(:`). with('tar xzf /tmp/tempfile -C /output') $?.stub :success? => true @writer.save_archive(:archive => 'archive_data', :output => '/output', :file => 'id.tar.gz', :extract => true).should be_true end it "should return false if the extract fails" do File.should_receive(:open).with('/tmp/tempfile', 'w') Heirloom::Writer.any_instance.should_receive(:`). with('tar xzf /tmp/tempfile -C /output') $?.stub :success? => false @logger_mock.should_receive(:error) @writer.save_archive(:archive => 'archive_data', :output => '/output', :file => 'id.tar.gz', :extract => true).should be_false end end context "extract is set to false" do it "should save the given archive object into the output directory" do File.should_receive(:open).with('/output/id.tar.gz', 'w'). and_return true @writer.save_archive :archive => 'archive_data', :output => '/output', :file => 'id.tar.gz', :extract => false end end end
Version data entries
14 entries across 14 versions & 1 rubygems