Skip to content

Commit 0488e30

Browse files
committed
Don't run writer open tests over all formats, just that being tested.
1 parent c9d4e7f commit 0488e30

1 file changed

Lines changed: 29 additions & 36 deletions

File tree

lib/rdf/spec/writer.rb

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
end
1212
let(:writer_class) { writer.class }
1313
let(:reader_class) { writer_class.format.reader}
14+
let(:format_class) { writer_class.format }
1415

1516
describe ".each" do
1617
it "yields each writer" do
@@ -63,56 +64,48 @@
6364
end
6465

6566
it "yields writer given file_name" do
66-
writer_class.format.each do |f|
67-
f.file_extensions.each_pair do |sym, content_type|
68-
writer_mock = double("writer")
69-
expect(writer_mock).to receive(:got_here)
70-
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
71-
writer_class.open("#{@basename}.#{sym}") do |r|
72-
expect(r).to be_a(RDF::Writer)
73-
writer_mock.got_here
74-
end
75-
end
76-
end
77-
end
78-
79-
it "yields writer given symbol" do
80-
writer_class.format.each do |f|
81-
sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
67+
format_class.file_extensions.each_pair do |sym, content_type|
8268
writer_mock = double("writer")
8369
expect(writer_mock).to receive(:got_here)
84-
expect(writer_class).to receive(:for).with(sym).and_return(writer_class)
85-
writer_class.open("#{@basename}.#{sym}", format: sym) do |r|
70+
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
71+
writer_class.open("#{@basename}.#{sym}") do |r|
8672
expect(r).to be_a(RDF::Writer)
8773
writer_mock.got_here
8874
end
8975
end
9076
end
9177

78+
it "yields writer given symbol" do
79+
sym = format_class.to_sym # Like RDF::NTriples::Format => :ntriples
80+
writer_mock = double("writer")
81+
expect(writer_mock).to receive(:got_here)
82+
expect(writer_class).to receive(:for).with(sym).and_return(writer_class)
83+
writer_class.open("#{@basename}.#{sym}", format: sym) do |r|
84+
expect(r).to be_a(RDF::Writer)
85+
writer_mock.got_here
86+
end
87+
end
88+
9289
it "yields writer given {file_name: file_name}" do
93-
writer_class.format.each do |f|
94-
f.file_extensions.each_pair do |sym, content_type|
95-
writer_mock = double("writer")
96-
expect(writer_mock).to receive(:got_here)
97-
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
98-
writer_class.open("#{@basename}.#{sym}", file_name: "#{@basename}.#{sym}") do |r|
99-
expect(r).to be_a(RDF::Writer)
100-
writer_mock.got_here
101-
end
90+
format_class.file_extensions.each_pair do |sym, content_type|
91+
writer_mock = double("writer")
92+
expect(writer_mock).to receive(:got_here)
93+
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
94+
writer_class.open("#{@basename}.#{sym}", file_name: "#{@basename}.#{sym}") do |r|
95+
expect(r).to be_a(RDF::Writer)
96+
writer_mock.got_here
10297
end
10398
end
10499
end
105100

106101
it "yields writer given {content_type: 'a/b'}" do
107-
writer_class.format.each do |f|
108-
f.content_types.each_pair do |content_type, formats|
109-
writer_mock = double("writer")
110-
expect(writer_mock).to receive(:got_here)
111-
expect(writer_class).to receive(:for).with(content_type: content_type, file_name: @basename).and_return(writer_class)
112-
writer_class.open(@basename, content_type: content_type) do |r|
113-
expect(r).to be_a(RDF::Writer)
114-
writer_mock.got_here
115-
end
102+
format_class.content_types.each_pair do |content_type, formats|
103+
writer_mock = double("writer")
104+
expect(writer_mock).to receive(:got_here)
105+
expect(writer_class).to receive(:for).with(content_type: content_type, file_name: @basename).and_return(writer_class)
106+
writer_class.open(@basename, content_type: content_type) do |r|
107+
expect(r).to be_a(RDF::Writer)
108+
writer_mock.got_here
116109
end
117110
end
118111
end

0 commit comments

Comments
 (0)