Sha256: 9cc78df9957222a4b8401796e62a33e84eaff40714bfaf6973195d7421b739b6

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

require "spec_helper"

describe Serializer do

  it "should be created with default values" do
    lambda {
      Serializer.new
    }.should_not raise_exception
  end

  describe "model" do

    before :each do
      @model = Model.new
      s = URI.parse("http://example.com/concepts#two-dimensional_seismic_imaging")
      p = URI.parse("http://www.w3.org/2000/01/rdf-schema#label")
      o = "2-D seismic imaging@en"
      @model.statements.create(:subject => s, :predicate => p, :object => o)
    end

    [:rdfxml, :ntriples, :turtle, :dot, :json].each do |format|
      it "should be serialized into a #{format} string" do
        serializer = Serializer.new(format)
        output = serializer.to_string(@model)
        output.should be_an_instance_of(String)
        output.should_not be_empty
      end
    end

    it "should be serialized into a file" do
      cleanup
      serializer = Serializer.new(:ntriples)
      serializer.to_file(@model, filename)
      File.should be_exists(filename)
      File.size(filename).should_not be_zero
      cleanup
    end


    private

    def cleanup
      File.delete(filename) if File.exists?(filename)
    end

    def filename
      "test_model.nt"
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redlander-0.3.6 spec/redlander/serializer_spec.rb
redlander-0.3.5 spec/redlander/serializer_spec.rb
redlander-0.3.3 spec/redlander/serializer_spec.rb
redlander-0.3.2 spec/redlander/serializer_spec.rb
redlander-0.3.1 spec/redlander/serializer_spec.rb
redlander-0.2.2 spec/redlander/serializer_spec.rb
redlander-0.2.1 spec/redlander/serializer_spec.rb