|
152 | 152 | it "should accept strings" do |
153 | 153 | expect { reader.new('') }.not_to raise_error |
154 | 154 | end |
| 155 | + |
| 156 | + it "sets version from reader option" do |
| 157 | + expect(reader.new('', version: '1.2').version).to eql '1.2' |
| 158 | + end |
155 | 159 | end |
156 | 160 |
|
157 | 161 | describe ".open" do |
|
566 | 570 | end |
567 | 571 | end |
568 | 572 | end |
| 573 | + |
| 574 | + it "warns if version is not 1.2 or 1.2-basic" do |
| 575 | + expect {parse('<http://subj> <http://pred> "Hello"@en--ltr .', rdfstar: true, version: '1.1', logger: logger)}.not_to raise_error |
| 576 | + expect(logger.to_s).to include("WARN") |
| 577 | + end |
| 578 | + |
| 579 | + it "warns if inline version is not 1.2 or 1.2-basic" do |
| 580 | + expect {parse(%{VERSION "1.1"\n<http://subj> <http://pred> "Hello"@en--ltr .}, rdfstar: true, logger: logger)}.not_to raise_error |
| 581 | + expect(logger.to_s).to include("WARN") |
| 582 | + end |
569 | 583 | end |
570 | 584 |
|
571 | 585 | context 'should parse a value that was written without passing through the writer encoding' do |
|
664 | 678 | end |
665 | 679 | end |
666 | 680 |
|
| 681 | + context "version" do |
| 682 | + { |
| 683 | + 'VERSION "1.2"': %( |
| 684 | + VERSION "1.2" |
| 685 | + <http://example/s> <http://example/p> <http://example/o> |
| 686 | + ), |
| 687 | + 'VERSION "1.2-basic"': %( |
| 688 | + VERSION "1.2-basic" |
| 689 | + <http://example/s> <http://example/p> <http://example/o> |
| 690 | + ), |
| 691 | + 'VERSION "1.1"': %( |
| 692 | + VERSION "1.1" |
| 693 | + <http://example/s> <http://example/p> <http://example/o> |
| 694 | + ), |
| 695 | + }.each do |name, input| |
| 696 | + it name do |
| 697 | + expect do |
| 698 | + parse(input, logger: logger) |
| 699 | + expect(logger.to_s).not_to include("WARN") |
| 700 | + end.not_to write.to(:error) |
| 701 | + end |
| 702 | + end |
| 703 | + |
| 704 | + it 'version "1.2" is an error' do |
| 705 | + expect do |
| 706 | + parse('version "1.2"', logger: logger) |
| 707 | + end.to raise_error(RDF::ReaderError) |
| 708 | + end |
| 709 | + |
| 710 | + it 'VERSION "1.0" is a warning' do |
| 711 | + expect do |
| 712 | + parse('VERSION "1.0"', logger: logger) |
| 713 | + end.not_to write.to(:error) |
| 714 | + expect(logger.to_s).to include('WARN') |
| 715 | + end |
| 716 | + end |
| 717 | + |
667 | 718 | context "triple terms" do |
668 | 719 | ill_statements = { |
669 | 720 | "subject-iii": '<<(<http://example/s1> <http://example/p1> <http://example/o1>)>> <http://example/p> <http://example/o> .', |
|
709 | 760 |
|
710 | 761 | statements.each do |name, st| |
711 | 762 | context name do |
712 | | - let(:graph) {parse(st, rdfstar: true)} |
| 763 | + let(:graph) {parse(st, rdfstar: true, logger: logger)} |
713 | 764 |
|
714 | 765 | it "creates an unquoted statement" do |
715 | 766 | expect(graph.count).to eql(1) |
716 | 767 | graph.statements.each do |stmt| |
717 | 768 | expect(stmt).not_to be_quoted |
718 | 769 | end |
| 770 | + expect(logger.to_s).not_to include("WARN") |
719 | 771 | end |
720 | 772 |
|
721 | 773 | it "statements which are object of another statement are triple terms" do |
722 | 774 | referencing = graph.statements.first |
723 | 775 | expect(referencing).to be_a_statement |
724 | 776 | expect(referencing.object).to be_a_statement |
725 | 777 | expect(referencing.object).to be_tripleTerm |
| 778 | + expect(logger.to_s).not_to include("WARN") |
| 779 | + end |
| 780 | + |
| 781 | + it "warns if version is not 1.2" do |
| 782 | + expect {parse(st, rdfstar: true, version: '1.1', logger: logger)}.not_to raise_error |
| 783 | + expect(logger.to_s).to include("WARN") |
| 784 | + end |
| 785 | + |
| 786 | + it "warns if inline version is not 1.2" do |
| 787 | + expect {parse(%{VERSION "1.1"\n#{st}}, rdfstar: true, logger: logger)}.not_to raise_error |
| 788 | + expect(logger.to_s).to include("WARN") |
| 789 | + |
| 790 | + expect {parse(%{VERSION "1.2-basic"\n#{st}}, rdfstar: true, logger: logger)}.not_to raise_error |
| 791 | + expect(logger.to_s).to include("WARN") |
726 | 792 | end |
727 | 793 | end |
728 | 794 | end |
|
0 commit comments