Sha256: 7af0388687838f13f2a13dc6551de95719ad52e75d177a5d2e34919986caf7fe

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

require 'rdf/spec'

module RDF_Format
  extend RSpec::SharedContext
  include RDF::Spec::Matchers

  before(:each) do
    raise raise '+@format_class+ must be defined in a before(:each) block' unless instance_variable_get('@format_class')
  end

  describe RDF::Format do
    subject {@format_class}
    describe ".for" do
      RDF::Format.file_extensions.each do |ext, formats|
        it "detects #{formats.first} using file path foo.#{ext}" do
          RDF::Format.for("foo.#{ext}").should == formats.first
        end

        it "detects #{formats.first} using file_name foo.#{ext}" do
          RDF::Format.for(:file_name => "foo.#{ext}").should == formats.first
        end

        it "detects #{formats.first} using file_extension #{ext}" do
          RDF::Format.for(:file_extension => ext).should == formats.first
        end
      end

      RDF::Format.content_types.each do |content_type, formats|
        it "detects #{formats.first} using content_type #{content_type}" do
          RDF::Format.for(:content_type => content_type).should == formats.first
        end
      end
    end
  
    describe ".reader" do
      it "returns a reader" do
        subject.each do |f|
          f.reader.should_not be_nil
        end
      end
    end
  
    describe ".writer" do
      ##
      # May not return a writer, only does if one is defined by the format
      it "returns a writer" do
        subject.each do |f|
          format_namespace = f.name.split('::')[0..-2].inject(Kernel) {|base, const| base.const_get(const)}
          f.writer.should_not be_nil if format_namespace.const_defined?(:Writer)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-spec-1.1.0.p3 lib/rdf/spec/format.rb
rdf-spec-1.0.7 lib/rdf/spec/format.rb
rdf-spec-1.1.0.p2 lib/rdf/spec/format.rb
rdf-spec-1.0.6 lib/rdf/spec/format.rb