Sha256: dd41cdaf74efac2ddef0ab9425943e99f31c0b31dbb47497b6e7f238819c963c

Contents?: true

Size: 1.1 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
magic_reveal-2.6.1.2 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.6.1.1 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.4.0.5 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.4.0.4 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.4.0.3 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.4.0.2 spec/magic_reveal/conductor_spec.rb
magic_reveal-2.4.0.1 spec/magic_reveal/conductor_spec.rb