Sha256: e5852dcb34f19419f256b72b9d33c4355de796ae3d38bafbdc4c812570f91123

Contents?: true

Size: 723 Bytes

Versions: 4

Compression:

Stored size: 723 Bytes

Contents

require 'spec_helper'
module Alf
  describe Renderer, ".by_mime_type" do

    context 'when mime type is unrecognized' do
      subject{
        Renderer.by_mime_type("no/suchone", [{id: "csv", name: "CSV"}])
      }

      it 'should raise an error' do
        lambda{
          subject
        }.should raise_error(UnsupportedMimeTypeError, /No renderer for `no\/suchone`/)
      end
    end

    context 'when such mime type is registered' do
      subject{
        Renderer.by_mime_type("text/csv", [{id: "csv", name: "CSV"}], col_sep: ";")
      }

      it{ should be_a(Renderer::CSV) }

      it 'should be wired correctly' do
        subject.execute("").should eq("id;name\ncsv;CSV\n")
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-io/renderer/class/test_by_mime_type.rb
alf-core-0.14.0 spec/unit/alf-io/renderer/class/test_by_mime_type.rb
alf-core-0.13.1 spec/unit/alf-io/renderer/class/test_by_mime_type.rb
alf-core-0.13.0 spec/unit/alf-io/renderer/class/test_by_mime_type.rb