Sha256: e1589c6eb1162377c42a0093a9e5bb18c18f292ab50486c1707d800acfbb747e

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'magic_reveal/conductor'

describe MagicReveal::Conductor do
  subject { described_class.new 'http://localhost/conductor_test/' }

  around do |example|
    Dir.mktmpdir('conductor') do |tmpdir|
      @tmpdir = Pathname.new tmpdir
      example.run
    end
  end

  its(:url) { should be_kind_of(URI) }

  describe '.fetch' do
    it 'should save a file' do
      subject.url = 'http://google.com/'
      save_file = @tmpdir + 'index.html'
      subject.fetch save_file
      save_file.should exist
    end
  end

  describe '.unpack' do
    let(:unpack_dir) { @tmpdir + "unpack-#{rand 200}" }
    context 'given a zipfile' do
      let(:zipfile) { EXAMPLE_DATA + 'wrapped.zip' }

      it 'unpacks and unwraps the zipfile' do
        subject.unpack zipfile, unpack_dir
        (unpack_dir + 'testfile.md').should exist
      end

      context 'and the unpack directory exists already' do
        before { unpack_dir.mkdir }

        it 'should raise an error' do
          expect { subject.unpack zipfile, unpack_dir }.to raise_error(MagicReveal::Error)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_reveal-2.6.1.4 spec/magic_reveal/conductor_spec.rb