Sha256: 1588d75d8b42f4db9b82bfa0857d5b315cff25420628a8be6db14a308d96a3ab

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"

RSpec.describe Vectory::InkscapeConverter do
  describe "#convert " do
    context "file has inproper format: svg extension, but eps content" do
      let(:input) { "spec/examples/eps_but_svg_extension.svg" }

      it "raises error" do
        with_tmp_dir do |dir|
          tmp_input_path = File.join(dir, File.basename(input))
          FileUtils.cp(input, tmp_input_path)

          expect do
            Vectory::InkscapeConverter.convert(tmp_input_path,
                                               "emf",
                                               "--export-type=emf")
          end.to raise_error(Vectory::ConversionError,
                             /parser error : Start tag expected/)
        end
      end
    end

    context "inkscape is not installed" do
      let(:input) { "spec/examples/eps2svg/img.eps" }

      it "raises error" do
        with_tmp_dir do |dir|
          tmp_input_path = File.join(dir, "image.eps")
          FileUtils.cp(input, tmp_input_path)

          expect(Vectory::InkscapeConverter.instance)
            .to receive(:inkscape_path).and_return(nil)

          expect do
            Vectory::InkscapeConverter.convert(tmp_input_path,
                                               "svg",
                                               "--export-type=svg")
          end.to raise_error(Vectory::InkscapeNotFoundError)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vectory-0.4.2 spec/vectory/inkscape_converter_spec.rb
vectory-0.4.1 spec/vectory/inkscape_converter_spec.rb
vectory-0.4.0 spec/vectory/inkscape_converter_spec.rb
vectory-0.3.0 spec/vectory/inkscape_converter_spec.rb