require 'spec_helper' describe RailsBlogEngine::ApplicationHelper do class SillyFilter < RailsBlogEngine::Filters::Base register_filter :silly def process(text, options) "Whee" end end describe ".markdown" do it "converts markdown text to HTML" do helper.markdown("_foo_ bar").should match(/foo<\/em> bar/) end it "does not pass scripts" do helper.markdown(""). should_not match(/script/) end it "applies filters" do helper.markdown("").should match(/Whee/) end context "for trusted users" do it "allows images" do helper.markdown("", :trusted? => true). should match(/", :trusted? => true). should_not match(/nofollow/) end it "allows code highlighting" do formatted = helper.markdown(< true)
EOD formatted.should match(/foo/) formatted.should match(/bar/) end end context "for untrusted users" do it "does not allow images" do helper.markdown("").should_not match(/").should match(/nofollow/) end end end end