Sha256: 80a3f8e32279e3ad77b5bf68abbf82b2f7c3b7af0d0d74cfefcd5c86a5e73ff4
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
require 'rdf/spec' RSpec.shared_examples 'an RDF::Format' do include RDF::Spec::Matchers before(:each) do raise 'format_class must be defined with let(:format_class)' unless defined? format_class end subject { format_class } describe ".for" do RDF::Format.file_extensions.each do |ext, formats| it "detects #{formats.first} using file path foo.#{ext}" do expect(RDF::Format.for("foo.#{ext}")).to eq formats.last end it "detects #{formats.first} using file_name foo.#{ext}" do expect(RDF::Format.for(file_name: "foo.#{ext}")).to eq formats.last end it "detects #{formats.first} using file_extension #{ext}" do expect(RDF::Format.for(file_extension: ext)).to eq formats.last end end RDF::Format.content_types.each do |content_type, formats| it "detects #{formats.first} using content_type #{content_type}" do expect(RDF::Format.for(content_type: content_type)).to eq formats.last end end end describe ".reader" do it "returns a reader" do subject.each do |f| expect(f.reader).not_to 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)} expect(f.writer).not_to be_nil if format_namespace.const_defined?(:Writer) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rdf-spec-2.0.0.beta1 | lib/rdf/spec/format.rb |