Sha256: 15bc387e2652de42f1d8f49dd50e90fe961e4b712ca80ac87dc8b7bdcb5f6be0
Contents?: true
Size: 1.65 KB
Versions: 9
Compression:
Stored size: 1.65 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| format_namespace = f.name.split('::')[0..-2].inject(Kernel) {|base, const| base.const_get(const)} expect(f.reader).not_to be_nil if format_namespace.const_defined?(:Reader) 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
9 entries across 9 versions & 1 rubygems