forked from citation-style-language/styles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindependent_styles_spec.rb
83 lines (64 loc) · 2.3 KB
/
independent_styles_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Independents.each_pair do |id, (filename, path, style)|
describe "independent style #{id}" do
it "is a valid CSL 1.0 style" do
CSL.validate(path).should == []
end
it "has a conventional file name" do
filename.should match(/^[a-z\d]+(-[a-z\d]+)*\.csl$/)
end
it "was successfully parsed" do
style.should be_a(CSL::Style)
end
unless style.nil?
it "is independent" do
style.should be_independent
end
it "has an info element" do
style.should have_info
end
it "has a self-link" do
style.should have_self_link
end
it "has an id" do
style.info.should have_id
end
it "the self-link is a valid style repository link" do
style.self_link.should == "http://www.zotero.org/styles/#{id}"
end
it "the self-link matches the style id" do
style.id.should == style.self_link
end
it "has an info/rights element" do
style.info.should have_rights
end
it "is licensed under a CC BY-SA license" do
(style.info.rights.text == 'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License' && style.info.rights[:license].should == 'http://creativecommons.org/licenses/by-sa/3.0/').should be_true
end
it "its template-link (if present) points to an existing independent style" do
if style.has_template_link?
link = style.template_link
link.should match(%r{http://www.zotero.org/styles/([a-z-]+)})
Independents.should have_key(link[/[^\/]+$/])
end
end
unless %w{ all bibtex blank national-archives-of-australia }.include?(id)
it "has at least one info/category" do
style.info.should have_categories
end
it "has a citation-format" do
style.citation_format.should_not be_nil
end
it "its citation-format is valid" do
style.citation_format.to_s.should match(/^author(-date)?|numeric|label|note/)
end
end
it "defines all macros that are referenced by text or key nodes" do
style.descendants!.each do |node|
if node.matches?(/^key|text$/, :macro => /./)
style.macros.should have_key(node[:macro])
end
end
end
end
end
end