Skip to content

Instantly share code, notes, and snippets.

@lightman76
Created August 25, 2016 13:56
Show Gist options
  • Save lightman76/d61ef640e9caa269bfe0ef0fe89c6e43 to your computer and use it in GitHub Desktop.
Save lightman76/d61ef640e9caa269bfe0ef0fe89c6e43 to your computer and use it in GitHub Desktop.
Failing spec for citeproc-ruby: Variables used only in conditionals inside of names->substitions are suppressed
# -*- coding: utf-8 -*-
require 'spec_helper'
module CiteProc
module Ruby
describe "Renderer#render_names" do
let(:renderer) { Renderer.new }
let(:node) { CSL::Style::Names.new }
let(:item) {
i = CiteProc::CitationItem.new(:id => 'ID-1')
i.data = CiteProc::Item.new(:id => 'ID-1')
i
}
let(:poe) { people(:poe) }
let(:philosophers) { CiteProc::Names.new('Plato and Socrates and Aristotle') }
describe "proper suppression of variables used in substitutions" do
before(:each) do
item.data[:type] = 'magazine-article'
item.data[:title] = 'My Article'
item.data[:"container-title"] = 'My Magazine'
item.data[:publisher] = 'Random House'
end
it "Use of variable in a conditional in a used substitution entry should not suppress that variable from being output later on" do
name_sub = ::CSL::Style::Substitute.new()
ifb1 = ::CSL::Style::Choose.new()
if1 = ::CSL::Style::Choose::Block.new(:variable=>"container-title", :match=>"any")
if1 << ::CSL::Style::Text.new(:variable=>'title', :quotes=>'true')
else1 = ::CSL::Style::Choose::Block.new
else1 << ::CSL::Style::Text.new(:variable=>'title', :"font-style"=>'italic')
ifb1 << if1
ifb1 << else1
name_sub << ifb1
node << name_sub
renderer.render_group(item, node)
expect(item.suppressed?(:"title")).to eq(true)
expect(item.suppressed?(:"container-title")).to eq(false)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment