require 'spec_helper' describe Banzai::Filter::PlantumlFilter do include FilterSpecHelper it 'replaces plantuml pre tag with img tag' do stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080") input = '
Bob -> Sara : Hello
' output = '
' doc = filter(input) expect(doc.to_s).to eq output end it 'does not replace plantuml pre tag with img tag if disabled' do stub_application_setting(plantuml_enabled: false) input = '
Bob -> Sara : Hello
' output = '
Bob -> Sara : Hello
' doc = filter(input) expect(doc.to_s).to eq output end it 'does not replace plantuml pre tag with img tag if url is invalid' do stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid") input = '
Bob -> Sara : Hello
' output = '
 PlantUML Error: cannot connect to PlantUML server at "invalid"
' doc = filter(input) expect(doc.to_s).to eq output end end