Sha256: 9f6288af16085f376634eba3ec28005388c6ea5222e0b1c7fd2f6e8eac25f91d
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require "spec_helper" require "pricecut" describe Pricecut::MarkdownVisitor do describe "#initialize" do it "initializes the output" do described_class.new.output.should_not be_nil end end describe "#visit" do let(:node) { parse "<test><strong>Test</strong></test>" } describe "with supported element" do before do # Define the element class so that # it is supported. # Maps to a <test> element. module Pricecut module Elements class Test < Element def output! p "?? "; yield_children; p " ??" end end end end end it "writes the output of the element to output" do subject.visit(node) subject.output.should eq("?? **Test** ??") end end describe "with unsupported element" do before do # Remove Test from the supported elements Pricecut::Elements.send(:remove_const, "Test") end it "skips the unsupported element" do subject.visit(node) subject.output.should eq("**Test**") end end end describe "#append_output" do it "appends text to the output" do subject.append_output("Output") subject.output.should eq("Output") end end describe "#visit_children" do before do class Node attr_reader :visited def accept(visitor) @visited = true end def children @children ||= (1..3).map { Node.new } end end end let(:node) { Node.new } it "visits the children of the node" do subject.visit_children(node) node.children.all?(&:visited).should be_true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pricecut-0.0.2 | spec/pricecut/markdown_visitor_spec.rb |