require 'spec_helper'
require 'magic_reveal/slide_renderer'
require 'tmpdir'
describe MagicReveal::SlideRenderer do
describe ".header" do
context "when no slides have been shown" do
before { subject.has_shown_slides = false }
it "starts with
}) end end context "without language" do it "has pre without class" do expect(subject.block_code(code, nil)). to match(%r{\A\s*\s*\Z}) end it "has no space between}) end end it "wraps the text in a" do expect(subject.block_code('whatever', nil)). to match(%r{tag" do text = "#{rand 99} text #{rand 99}" expect(subject.block_code(text, nil)). to match(%r{
#{Regexp.quote text}
}) end it "escapes the code text" do CGI.should_receive(:escapeHTML).and_return('text') subject.block_code('whatever', nil) end it "ends with
and " do
expect(subject.block_code('whatever', nil)).
to match(%r{]*>})
end
it "has no space between
and
" do
expect(subject.block_code('whatever', nil)).
to match(%r{
})
end
end
describe "prepare_code" do
context "with @@source = filename" do
around { |example| Dir.mktmpdir { |dir| @tmpdir = Pathname.new dir; example.run } }
let(:filename) { @tmpdir + "file#{rand 99}" }
it "loads the contents from filename" do
text = "#{rand 99} bottles of beer"
filename.open('w') { |f| f.write text }
expect(subject.prepare_code "@@source = #{filename}").to eq(text)
end
end
context "without @@source" do
it "returns the text" do
text = "#{rand 99} luft balloons."
expect(subject.prepare_code text).to eq(text)
end
end
end
end