Sha256: 512096e7f617f3fb73a4323e2f84bb5427506455e191110a5e6e94bfccee46f2

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Sanitizer do
  
  describe "sanitize" do
   
    it "should strip all tags" do
      html = "<div><p>Oi <b>como</b> <a href='/xxx/'>Vai</a></p><!-- s --></div>" 
      output = Sanitizer.sanitize(html)
      output.should == 'Oi como Vai'
    end
    
    it "should clean spaces and tags" do
      html = "<p>Oi <b>como</b>     
    Vai</p>"
      output = Sanitizer.sanitize(html)
      output.should == 'Oi como Vai'
    end
    
    it "should clean '&' entries" do
      html = "Eu & você"
      output = Sanitizer.sanitize(html)
      output.should == 'Eu &amp; você'
    end
    
    it "should not remove valid entries" do
      html = "Eu &amp; você"
      output = Sanitizer.sanitize(html)
      output.should == 'Eu &amp; você'
    end
  end
  
  describe "strip_tags" do
    
    it "should remove only <b> tags" do
       html = "<p>Oi <b>como</b> <a href='/xxx/'>Vai</a></p><!-- s -->" 
      output = Sanitizer.strip_tags(html, 'b')
      output.should == "<p>Oi como <a href='/xxx/'>Vai</a></p><!-- s -->"
    end
    
    it "should remove only <b> and <a> tags" do
       html = "<p>Oi <b>como</b> <a href='/xxx/'>Vai</a></p><!-- s -->" 
      output = Sanitizer.strip_tags(html, 'a', 'b')
      output.should == "<p>Oi como Vai</p><!-- s -->"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sanitizer-0.1.1 spec/sanitizer_spec.rb