Sha256: e667c11a872abd5b6068430f683352b4f68ccad0a203f0aba4a51845be46e7b7
Contents?: true
Size: 1.79 KB
Versions: 5
Compression:
Stored size: 1.79 KB
Contents
require 'test_helper.rb' class SlideParserTest < Clean::Test::TestCase class RememberingRenderer attr_reader :rendered_slides def initialize @rendered_slides = [] end def render_slide(slide_type,content) @rendered_slides << [slide_type,content] end def content @rendered_slides.inspect end end test_that "title is grabbed from the first line" do Given { @title = any_string @lines = [ @title, any_string, any_string ] @parser = Trickster::SlideParser.new(@lines,nil) } Then { assert_equal @title,@parser.title } end test_that "the renderer is called for each slide" do Given { @slides = [ ['TITLE',[any_string,any_string]], ['BULLETS',[any_string,any_string]], ]; lines = @slides.map { |(slide_type,content)| ["!#{slide_type}",content] }.flatten lines.unshift(any_string) @renderer = RememberingRenderer.new @parser = Trickster::SlideParser.new(lines,@renderer) } When { @resulting_content = @parser.body } Then { assert_equal @slides.inspect,@resulting_content assert_equal @slides,@renderer.rendered_slides } end test_that "comments are ignored" do Given { @slides = [ ['TITLE',[any_string,any_string]], ['BULLETS',[any_string,any_string]], ]; lines = @slides.map { |(slide_type,content)| ["!#{slide_type}",content] }.flatten lines.unshift(any_string) @renderer = RememberingRenderer.new @parser = Trickster::SlideParser.new(lines,@renderer) } When { @resulting_content = @parser.body } Then { assert_equal @slides[0..2].inspect,@resulting_content assert_equal @slides[0..2],@renderer.rendered_slides } end end
Version data entries
5 entries across 5 versions & 1 rubygems