-
-
Notifications
You must be signed in to change notification settings - Fork 398
/
Copy pathlibrary_spec.rb
48 lines (40 loc) · 1.47 KB
/
library_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true
RSpec.describe YARD::Tags::Library do
def tag(docstring)
Docstring.new(docstring).tags.first
end
describe "#see_tag" do
it "takes a URL" do
expect(tag("@see http://example.com").name).to eq "http://example.com"
end
it "takes an object path" do
expect(tag("@see String#reverse").name).to eq "String#reverse"
end
it "takes a description after the url/object" do
tag = tag("@see http://example.com An Example Site")
expect(tag.name).to eq "http://example.com"
expect(tag.text).to eq "An Example Site"
end
end
describe ".define_tag" do
it "allows defining tags with '.' in the name (x.y.z defines method x_y_z)" do
Tags::Library.define_tag("foo", 'x.y.z')
Tags::Library.define_tag("foo2", 'x.y.zz', Tags::OverloadTag)
expect(Tags::Library.instance.method(:x_y_z_tag)).not_to be nil
expect(Tags::Library.instance.method(:x_y_zz_tag)).not_to be nil
expect(tag('@x.y.z foo bar').text).to eq 'foo bar'
expect(tag('@x.y.zz foo(bar)').signature).to eq 'foo(bar)'
end
end
describe "#tag.explain_types" do
it "can explain tag types" do
expect(tag("@return [A, B<String>]").explain_types).to eq "an A; a B of (Strings)"
end
it "returns nil if no types present" do
expect(tag("@return").explain_types).to eq nil
end
it "returns nil if types are not parsable" do
expect(tag("@return [$]").explain_types).to eq nil
end
end
end