Skip to content

Commit

Permalink
rspec for Ruby 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Nov 11, 2024
1 parent 5a80661 commit de7084d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/relaton-render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
require "relaton/render/parse/parse"
require "relaton/render/utils/utils"
require "isodoc/i18n"

require "base64" # Liquid
require "bigdecimal" # Liquid
2 changes: 2 additions & 0 deletions relaton-render.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "relaton-bib", ">= 1.13.0"
spec.add_dependency "twitter_cldr"
spec.add_dependency "tzinfo-data" # we need this for windows only
spec.add_dependency "base64" # Liquid
spec.add_dependency "bigdecimal" # Liquid
#spec.metadata["rubygems_mfa_required"] = "true"
end
21 changes: 7 additions & 14 deletions spec/citation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,32 @@
etal = <<~TEMPLATE
{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %} <em>et al.</em>
TEMPLATE
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi, Anderson, Hering, Mustaţă <em>et al.</em>", :date=>"2022", :citation=>"Aluffi, Anderson, Hering, Mustaţă <em>et al.</em> 2022", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new(
authorcitetemplate: { one: "{{ nonpersonal[0] }}", etal_count: 4,
etal: etal },
)
expect(p.render_all(input, type: "author-date"))
.to be_equivalent_to output
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi, Anderson, Hering <em>et al.</em>", :date=>"2022", :citation=>"Aluffi, Anderson, Hering <em>et al.</em> 2022", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new(
authorcitetemplate: { one: "{{ nonpersonal[0] }}", etal_count: 4,
etal_display: 3, etal: etal },
)
expect(p.render_all(input, type: "author-date"))
.to be_equivalent_to output
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi, Anderson <em>et al.</em>", :date=>"2022", :citation=>"Aluffi, Anderson <em>et al.</em> 2022", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new(
authorcitetemplate: { one: "{{ nonpersonal[0] }}", etal_count: 4,
etal_display: 2, etal: etal },
)
expect(p.render_all(input, type: "author-date"))
.to be_equivalent_to output
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi <em>et al.</em>", :date=>"2022", :citation=>"Aluffi <em>et al.</em> 2022", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new(
authorcitetemplate: { one: "{{ nonpersonal[0] }}", etal_count: 4,
etal_display: 1, etal: etal },
Expand Down Expand Up @@ -286,12 +282,11 @@
</bibitem>
</references>
INPUT
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi, Anderson, Hering, Mustaţă and Payne", :date=>"2022a", :citation=>"Aluffi, Anderson, Hering, Mustaţă and Payne 2022a", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022a. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."},
"B"=>{:author=>"Aluffi, Anderson, Hering, Mustaţă and Payne", :date=>"2022b", :citation=>"Aluffi, Anderson, Hering, Mustaţă and Payne 2022b", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022b. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."},
"C"=>{:author=>"Aluffi, Anderson, Hering, Mustaţă and Payne", :date=>"2021", :citation=>"Aluffi, Anderson, Hering, Mustaţă and Payne 2021", :formattedref=>"ALUFFI, Paolo, David ANDERSON, Milena HERING, Mircea MUSTAŢĂ and Sam PAYNE (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2021. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."},
"D"=>{:author=>"Aluffi and Anderson", :date=>"2022", :citation=>"Aluffi and Anderson 2022", :formattedref=>"ALUFFI, Paolo and David ANDERSON (eds.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. DOI: https://doi.org/10.1017/9781108877831. ISBN: 9781108877831. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new
expect(p.render_all(input, type: "author-date"))
.to be_equivalent_to output
Expand Down Expand Up @@ -380,12 +375,11 @@
template2 = <<~TEMPLATE
{{ creatornames }} ({{date}}) . <em>{{ title }}</em> {{ uri }}. Accessed: {{ date_accessed }}.
TEMPLATE
output = <<~OUTPUT
output =
{"A"=>{:author=>"Aluffi", :date=>"2021", :citation=>"Aluffi 2021", :formattedref=>"ALUFFI, Paolo (2021). <em>Book 1</em> <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>."},
"B"=>{:author=>"Aluffi", :date=>"2022", :citation=>"Aluffi 2022", :formattedref=>"ALUFFI, Paolo (2022). <em>Book 2</em> <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>."},
"C"=>{:author=>"Aluffi", :date=>"2023", :citation=>"Aluffi 2023", :formattedref=>"ALUFFI, Paolo (2023). <em>Standard 1</em> <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>. Accessed: #{Date.today.strftime('%B %-d, %Y')}."},
"D"=>{:author=>"Aluffi", :date=>"2024", :citation=>"Aluffi 2024", :formattedref=>"ALUFFI, Paolo (2024). <em>Standard 2</em> <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>. Accessed: #{Date.today.strftime('%B %-d, %Y')}."}}
OUTPUT
p = Relaton::Render::General
.new(template: { book: template1, standard: template2 })
expect(p.render_all(input, type: "author-date"))
Expand Down Expand Up @@ -445,10 +439,9 @@
</bibitem>
</references>
INPUT
output = <<~OUTPUT
output =
{"A"=>{:citation=>nil, :formattedref=>"ALUFFI, Paolo (ed.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. ABC1. 1 vol."},
"B"=>{:citation=>nil, :formattedref=>"ALUFFI, Paolo (ed.). <em>Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</em>. 1st edition. (London Mathematical Society Lecture Note Series 472.) Cambridge, UK: Cambridge University Press. 2022. ABC2. 1 vol."}}
OUTPUT
p = Relaton::Render::General.new
expect(p.render_all(input, type: nil))
.to be_equivalent_to output
Expand Down

0 comments on commit de7084d

Please sign in to comment.