rdf-spec 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,25 +13,25 @@ module RDF_Reader
13
13
  describe ".each" do
14
14
  it "yields each reader" do
15
15
  @reader_class.each do |r|
16
- r.should_not be_nil
16
+ expect(r).not_to be_nil
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  describe ".open" do
22
22
  before(:each) do
23
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
23
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
24
24
  end
25
25
 
26
26
  it "yields reader given file_name" do
27
27
  @reader_class.format.each do |f|
28
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
28
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
29
29
  f.file_extensions.each_pair do |sym, content_type|
30
- reader_mock = mock("reader")
31
- reader_mock.should_receive(:got_here)
32
- @reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
30
+ reader_mock = double("reader")
31
+ expect(reader_mock).to receive(:got_here)
32
+ expect(@reader_class).to receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
33
33
  @reader_class.open("foo.#{sym}") do |r|
34
- r.should be_a(RDF::Reader)
34
+ expect(r).to be_a(RDF::Reader)
35
35
  reader_mock.got_here
36
36
  end
37
37
  end
@@ -40,13 +40,13 @@ module RDF_Reader
40
40
 
41
41
  it "yields reader given symbol" do
42
42
  @reader_class.format.each do |f|
43
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
43
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
44
44
  sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
45
- reader_mock = mock("reader")
46
- reader_mock.should_receive(:got_here)
47
- @reader_class.should_receive(:for).with(sym).and_return(@reader_class)
45
+ reader_mock = double("reader")
46
+ expect(reader_mock).to receive(:got_here)
47
+ expect(@reader_class).to receive(:for).with(sym).and_return(@reader_class)
48
48
  @reader_class.open("foo.#{sym}", :format => sym) do |r|
49
- r.should be_a(RDF::Reader)
49
+ expect(r).to be_a(RDF::Reader)
50
50
  reader_mock.got_here
51
51
  end
52
52
  end
@@ -54,13 +54,13 @@ module RDF_Reader
54
54
 
55
55
  it "yields reader given {:file_name => file_name}" do
56
56
  @reader_class.format.each do |f|
57
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
57
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
58
58
  f.file_extensions.each_pair do |sym, content_type|
59
- reader_mock = mock("reader")
60
- reader_mock.should_receive(:got_here)
61
- @reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
59
+ reader_mock = double("reader")
60
+ expect(reader_mock).to receive(:got_here)
61
+ expect(@reader_class).to receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
62
62
  @reader_class.open("foo.#{sym}", :file_name => "foo.#{sym}") do |r|
63
- r.should be_a(RDF::Reader)
63
+ expect(r).to be_a(RDF::Reader)
64
64
  reader_mock.got_here
65
65
  end
66
66
  end
@@ -69,13 +69,13 @@ module RDF_Reader
69
69
 
70
70
  it "yields reader given {:content_type => 'a/b'}" do
71
71
  @reader_class.format.each do |f|
72
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
72
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
73
73
  f.content_types.each_pair do |content_type, formats|
74
- reader_mock = mock("reader")
75
- reader_mock.should_receive(:got_here)
76
- @reader_class.should_receive(:for).with(:content_type => content_type, :file_name => "foo").and_return(@reader_class)
74
+ reader_mock = double("reader")
75
+ expect(reader_mock).to receive(:got_here)
76
+ expect(@reader_class).to receive(:for).with(:content_type => content_type, :file_name => "foo").and_return(@reader_class)
77
77
  @reader_class.open("foo", :content_type => content_type) do |r|
78
- r.should be_a(RDF::Reader)
78
+ expect(r).to be_a(RDF::Reader)
79
79
  reader_mock.got_here
80
80
  end
81
81
  end
@@ -86,27 +86,27 @@ module RDF_Reader
86
86
  describe ".format" do
87
87
  it "returns itself even if given explicit format" do
88
88
  other_format = @reader_class == RDF::NTriples::Reader ? :nquads : :ntriples
89
- @reader_class.for(other_format).should == @reader_class
89
+ expect(@reader_class.for(other_format)).to eq @reader_class
90
90
  end
91
91
  end
92
92
 
93
93
  describe ".new" do
94
94
  it "sets @input to StringIO given a string" do
95
- reader_mock = mock("reader")
96
- reader_mock.should_receive(:got_here)
95
+ reader_mock = double("reader")
96
+ expect(reader_mock).to receive(:got_here)
97
97
  @reader_class.new("string") do |r|
98
98
  reader_mock.got_here
99
- r.instance_variable_get(:@input).should be_a(StringIO)
99
+ expect(r.instance_variable_get(:@input)).to be_a(StringIO)
100
100
  end
101
101
  end
102
102
 
103
103
  it "sets @input to input given something other than a string" do
104
- reader_mock = mock("reader")
105
- reader_mock.should_receive(:got_here)
104
+ reader_mock = double("reader")
105
+ expect(reader_mock).to receive(:got_here)
106
106
  file = StringIO.new("")
107
107
  @reader_class.new(file) do |r|
108
108
  reader_mock.got_here
109
- r.instance_variable_get(:@input).should == file
109
+ expect(r.instance_variable_get(:@input)).to eq file
110
110
  end
111
111
  end
112
112
 
@@ -114,37 +114,37 @@ module RDF_Reader
114
114
  # Either set validate, or through error, due to invalid input (null input may be invalid)
115
115
  begin
116
116
  @reader_class.new("string", :validate => true) do |r|
117
- r.send(:validate?).should be_true
117
+ expect(r).to be_valid
118
118
  end
119
119
  rescue
120
- $!.should be_a(RDF::ReaderError) # An error is acceptable
120
+ expect($!).to be_a(RDF::ReaderError) # An error is acceptable
121
121
  end
122
122
  end
123
123
 
124
124
  it "sets canonicalize given :canonicalize => true" do
125
- reader_mock = mock("reader")
126
- reader_mock.should_receive(:got_here)
125
+ reader_mock = double("reader")
126
+ expect(reader_mock).to receive(:got_here)
127
127
  @reader_class.new("string", :canonicalize => true) do |r|
128
128
  reader_mock.got_here
129
- r.send(:canonicalize?).should be_true
129
+ expect(r).to be_canonicalize
130
130
  end
131
131
  end
132
132
 
133
133
  it "sets intern given :intern => true" do
134
- reader_mock = mock("reader")
135
- reader_mock.should_receive(:got_here)
134
+ reader_mock = double("reader")
135
+ expect(reader_mock).to receive(:got_here)
136
136
  @reader_class.new("string", :intern => true) do |r|
137
137
  reader_mock.got_here
138
- r.send(:intern?).should be_true
138
+ expect(r).to be_intern
139
139
  end
140
140
  end
141
141
 
142
142
  it "sets prefixes given :prefixes => {}" do
143
- reader_mock = mock("reader")
144
- reader_mock.should_receive(:got_here)
143
+ reader_mock = double("reader")
144
+ expect(reader_mock).to receive(:got_here)
145
145
  @reader_class.new("string", :prefixes => {:a => "b"}) do |r|
146
146
  reader_mock.got_here
147
- r.prefixes.should == {:a => "b"}
147
+ expect(r.prefixes).to eq({:a => "b"})
148
148
  end
149
149
  end
150
150
  end
@@ -152,7 +152,7 @@ module RDF_Reader
152
152
  describe "#prefixes=" do
153
153
  it "sets prefixes from hash" do
154
154
  @reader.prefixes = {:a => "b"}
155
- @reader.prefixes.should == {:a => "b"}
155
+ expect(@reader.prefixes).to eq({:a => "b"})
156
156
  end
157
157
  end
158
158
 
@@ -163,8 +163,8 @@ module RDF_Reader
163
163
  "foo" => "bar",
164
164
  }.each_pair do |pfx, uri|
165
165
  it "sets prefix(#{pfx}) to #{uri}" do
166
- @reader.prefix(pfx, uri).should == uri
167
- @reader.prefix(pfx).should == uri
166
+ expect(@reader.prefix(pfx, uri)).to eq uri
167
+ expect(@reader.prefix(pfx)).to eq uri
168
168
  end
169
169
  end
170
170
  end
@@ -31,7 +31,7 @@ module RDF_Transaction
31
31
 
32
32
  describe "#readable?" do
33
33
  it "returns false" do
34
- @transaction.readable?.should be_false
34
+ expect(@transaction.readable?).to be_false
35
35
  end
36
36
  end
37
37
 
@@ -26,8 +26,8 @@ module RDF_Writable
26
26
  pending("writability", :unless => subject.writable?) do
27
27
  reader = RDF::NTriples::Reader.new(File.open(@filename)).to_a
28
28
  subject << reader
29
- subject.should have_statement(statement)
30
- subject.count.should == count
29
+ expect(subject).to have_statement(statement)
30
+ expect(subject.count).to eq count
31
31
  end
32
32
  end
33
33
 
@@ -35,8 +35,8 @@ module RDF_Writable
35
35
  pending("writability", :unless => subject.writable?) do
36
36
  graph = RDF::Graph.new << @statements
37
37
  subject << graph
38
- subject.should have_statement(statement)
39
- subject.count.should == count
38
+ expect(subject).to have_statement(statement)
39
+ expect(subject.count).to eq count
40
40
  end
41
41
  end
42
42
 
@@ -44,8 +44,8 @@ module RDF_Writable
44
44
  pending("writability", :unless => subject.writable?) do
45
45
  enumerable = @statements.dup.extend(RDF::Enumerable)
46
46
  subject << enumerable
47
- subject.should have_statement(statement)
48
- subject.count.should == count
47
+ expect(subject).to have_statement(statement)
48
+ expect(subject.count).to eq count
49
49
  end
50
50
  end
51
51
 
@@ -54,25 +54,25 @@ module RDF_Writable
54
54
  mock = double('mock')
55
55
  mock.stub(:to_rdf).and_return(@statements)
56
56
  subject << mock
57
- subject.should have_statement(statement)
58
- subject.count.should == count
57
+ expect(subject).to have_statement(statement)
58
+ expect(subject.count).to eq count
59
59
  end
60
60
  end
61
61
 
62
62
  it "inserts a statement" do
63
63
  pending("writability", :unless => subject.writable?) do
64
64
  subject << statement
65
- subject.should have_statement(statement)
66
- subject.count.should == 1
65
+ expect(subject).to have_statement(statement)
66
+ expect(subject.count).to eq 1
67
67
  end
68
68
  end
69
69
 
70
70
  it "inserts an invalid statement" do
71
71
  pending("writability", :unless => subject.writable?) do
72
72
  s = RDF::Statement.from([nil, nil, nil])
73
- s.should_not be_valid
73
+ expect(s).not_to be_valid
74
74
  subject << s
75
- subject.count.should == 1
75
+ expect(subject.count).to eq 1
76
76
  end
77
77
  end
78
78
  end
@@ -80,20 +80,20 @@ module RDF_Writable
80
80
  context "when inserting statements" do
81
81
  it "should support #insert" do
82
82
  pending("writability", :unless => subject.writable?) do
83
- subject.should respond_to(:insert)
83
+ expect(subject).to respond_to(:insert)
84
84
  end
85
85
  end
86
86
 
87
87
  it "should not raise errors" do
88
88
  pending("writability", :unless => subject.writable?) do
89
- lambda { subject.insert(statement) }.should_not raise_error
89
+ expect { subject.insert(statement) }.not_to raise_error
90
90
  end
91
91
  end
92
92
 
93
93
  it "should support inserting one statement at a time" do
94
94
  pending("writability", :unless => subject.writable?) do
95
95
  subject.insert(statement)
96
- subject.should have_statement(statement)
96
+ expect(subject).to have_statement(statement)
97
97
  end
98
98
  end
99
99
 
@@ -106,7 +106,7 @@ module RDF_Writable
106
106
  it "should insert statements successfully" do
107
107
  pending("writability", :unless => subject.writable?) do
108
108
  subject.insert(*@statements)
109
- subject.count.should == count
109
+ expect(subject.count).to eq count
110
110
  end
111
111
  end
112
112
 
@@ -114,7 +114,7 @@ module RDF_Writable
114
114
  pending("writability", :unless => subject.writable?) do
115
115
  subject.insert(statement)
116
116
  subject.insert(statement)
117
- subject.count.should == 1
117
+ expect(subject.count).to eq 1
118
118
  end
119
119
  end
120
120
 
@@ -130,7 +130,7 @@ module RDF_Writable
130
130
  subject.insert(s2)
131
131
  subject.insert(s3)
132
132
  # If contexts are not suported, all three are redundant
133
- subject.count.should == (@supports_context ? 3 : 1)
133
+ expect(subject.count).to eq (@supports_context ? 3 : 1)
134
134
  end
135
135
  end
136
136
  end
@@ -15,23 +15,23 @@ module RDF_Writer
15
15
  describe ".each" do
16
16
  it "yields each writer" do
17
17
  @writer_class.each do |r|
18
- r.should_not be_nil
18
+ expect(r).not_to be_nil
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
23
  describe ".buffer" do
24
24
  it "calls .new with buffer and other arguments" do
25
- @writer_class.should_receive(:new)
25
+ expect(@writer_class).to receive(:new)
26
26
  @writer_class.buffer do |r|
27
- r.should be_a(@writer_class)
27
+ expect(r).to be_a(@writer_class)
28
28
  end
29
29
  end
30
30
  end
31
31
 
32
32
  describe ".open" do
33
33
  before(:each) do
34
- RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
34
+ RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
35
35
  @dir = Dir.mktmpdir
36
36
  @basename = File.join(@dir, "foo")
37
37
  end
@@ -43,11 +43,11 @@ module RDF_Writer
43
43
  it "yields writer given file_name" do
44
44
  @writer_class.format.each do |f|
45
45
  f.file_extensions.each_pair do |sym, content_type|
46
- writer_mock = mock("writer")
47
- writer_mock.should_receive(:got_here)
48
- @writer_class.should_receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
46
+ writer_mock = double("writer")
47
+ expect(writer_mock).to receive(:got_here)
48
+ expect(@writer_class).to receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
49
49
  @writer_class.open("#{@basename}.#{sym}") do |r|
50
- r.should be_a(RDF::Writer)
50
+ expect(r).to be_a(RDF::Writer)
51
51
  writer_mock.got_here
52
52
  end
53
53
  end
@@ -57,11 +57,11 @@ module RDF_Writer
57
57
  it "yields writer given symbol" do
58
58
  @writer_class.format.each do |f|
59
59
  sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
60
- writer_mock = mock("writer")
61
- writer_mock.should_receive(:got_here)
62
- @writer_class.should_receive(:for).with(sym).and_return(@writer_class)
60
+ writer_mock = double("writer")
61
+ expect(writer_mock).to receive(:got_here)
62
+ expect(@writer_class).to receive(:for).with(sym).and_return(@writer_class)
63
63
  @writer_class.open("#{@basename}.#{sym}", :format => sym) do |r|
64
- r.should be_a(RDF::Writer)
64
+ expect(r).to be_a(RDF::Writer)
65
65
  writer_mock.got_here
66
66
  end
67
67
  end
@@ -70,11 +70,11 @@ module RDF_Writer
70
70
  it "yields writer given {:file_name => file_name}" do
71
71
  @writer_class.format.each do |f|
72
72
  f.file_extensions.each_pair do |sym, content_type|
73
- writer_mock = mock("writer")
74
- writer_mock.should_receive(:got_here)
75
- @writer_class.should_receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
73
+ writer_mock = double("writer")
74
+ expect(writer_mock).to receive(:got_here)
75
+ expect(@writer_class).to receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
76
76
  @writer_class.open("#{@basename}.#{sym}", :file_name => "#{@basename}.#{sym}") do |r|
77
- r.should be_a(RDF::Writer)
77
+ expect(r).to be_a(RDF::Writer)
78
78
  writer_mock.got_here
79
79
  end
80
80
  end
@@ -84,11 +84,11 @@ module RDF_Writer
84
84
  it "yields writer given {:content_type => 'a/b'}" do
85
85
  @writer_class.format.each do |f|
86
86
  f.content_types.each_pair do |content_type, formats|
87
- writer_mock = mock("writer")
88
- writer_mock.should_receive(:got_here)
89
- @writer_class.should_receive(:for).with(:content_type => content_type, :file_name => @basename).and_return(@writer_class)
87
+ writer_mock = double("writer")
88
+ expect(writer_mock).to receive(:got_here)
89
+ expect(@writer_class).to receive(:for).with(:content_type => content_type, :file_name => @basename).and_return(@writer_class)
90
90
  @writer_class.open(@basename, :content_type => content_type) do |r|
91
- r.should be_a(RDF::Writer)
91
+ expect(r).to be_a(RDF::Writer)
92
92
  writer_mock.got_here
93
93
  end
94
94
  end
@@ -99,45 +99,44 @@ module RDF_Writer
99
99
  describe ".format" do
100
100
  it "returns itself even if given explicit format" do
101
101
  other_format = @writer_class == RDF::NTriples::Writer ? :nquads : :ntriples
102
- @writer_class.for(other_format).should == @writer_class
102
+ expect(@writer_class.for(other_format)).to eq @writer_class
103
103
  end
104
104
  end
105
105
 
106
106
  describe ".new" do
107
107
  it "sets @output to $stdout by default" do
108
- writer_mock = mock("writer")
109
- writer_mock.should_receive(:got_here)
108
+ writer_mock = double("writer")
109
+ expect(writer_mock).to receive(:got_here)
110
110
  save, $stdout = $stdout, StringIO.new
111
111
 
112
112
  @writer_class.new do |r|
113
113
  writer_mock.got_here
114
- r.instance_variable_get(:@output).should == $stdout
114
+ expect(r.instance_variable_get(:@output)).to eq $stdout
115
115
  end
116
116
  $stdout = save
117
117
  end
118
118
 
119
119
  it "sets @output to file given something other than a string" do
120
- writer_mock = mock("writer")
121
- writer_mock.should_receive(:got_here)
120
+ writer_mock = double("writer")
121
+ expect(writer_mock).to receive(:got_here)
122
122
  file = StringIO.new
123
- file.should_receive(:write).any_number_of_times
124
123
  @writer_class.new(file) do |r|
125
124
  writer_mock.got_here
126
- r.instance_variable_get(:@output).should == file
125
+ expect(r.instance_variable_get(:@output)).to eq file
127
126
  end
128
127
  end
129
128
 
130
129
  it "sets prefixes given :prefixes => {}" do
131
- writer_mock = mock("writer")
132
- writer_mock.should_receive(:got_here)
130
+ writer_mock = double("writer")
131
+ expect(writer_mock).to receive(:got_here)
133
132
  @writer_class.new(StringIO.new, :prefixes => {:a => "b"}) do |r|
134
133
  writer_mock.got_here
135
- r.prefixes.should == {:a => "b"}
134
+ expect(r.prefixes).to eq({:a => "b"})
136
135
  end
137
136
  end
138
137
 
139
138
  #it "calls #write_prologue" do
140
- # writer_mock = mock("writer")
139
+ # writer_mock = double("writer")
141
140
  # writer_mock.should_receive(:got_here)
142
141
  # @writer_class.any_instance.should_receive(:write_prologue)
143
142
  # @writer_class.new(StringIO.new) do |r|
@@ -146,7 +145,7 @@ module RDF_Writer
146
145
  #end
147
146
  #
148
147
  #it "calls #write_epilogue" do
149
- # writer_mock = mock("writer")
148
+ # writer_mock = double("writer")
150
149
  # writer_mock.should_receive(:got_here)
151
150
  # @writer_class.any_instance.should_receive(:write_epilogue)
152
151
  # @writer_class.new(StringIO.new) do |r|
@@ -158,7 +157,7 @@ module RDF_Writer
158
157
  describe "#prefixes=" do
159
158
  it "sets prefixes from hash" do
160
159
  @writer.prefixes = {:a => "b"}
161
- @writer.prefixes.should == {:a => "b"}
160
+ expect(@writer.prefixes).to eq({:a => "b"})
162
161
  end
163
162
  end
164
163
 
@@ -169,8 +168,8 @@ module RDF_Writer
169
168
  "foo" => "bar",
170
169
  }.each_pair do |pfx, uri|
171
170
  it "sets prefix(#{pfx}) to #{uri}" do
172
- @writer.prefix(pfx, uri).should == uri
173
- @writer.prefix(pfx).should == uri
171
+ expect(@writer.prefix(pfx, uri)).to eq uri
172
+ expect(@writer.prefix(pfx)).to eq uri
174
173
  end
175
174
  end
176
175
  end