debian-mirror-gitlab/spec/lib/gitlab/asciidoc_spec.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
require 'spec_helper'
require 'nokogiri'
module Gitlab
2015-12-23 02:04:40 +05:30
describe Asciidoc, lib: true do
2015-09-11 14:41:01 +05:30
let(:input) { '<b>ascii</b>' }
let(:context) { {} }
let(:html) { 'H<sub>2</sub>O' }
context "without project" do
2016-09-13 17:45:13 +05:30
it "converts the input using Asciidoctor and default options" do
2015-09-11 14:41:01 +05:30
expected_asciidoc_opts = {
safe: :secure,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS
}
expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html)
expect( render(input, context) ).to eql html
end
context "with asciidoc_opts" do
let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
2016-09-13 17:45:13 +05:30
it "merges the options with default ones" do
2015-09-11 14:41:01 +05:30
expected_asciidoc_opts = {
safe: :safe,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo']
}
expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html)
render(input, context, asciidoc_opts)
end
end
end
def render(*args)
described_class.render(*args)
end
end
end