Sha256: 610b26214c0b9abd06bee03ea2c520d6d153b863358d09f634809d815e90e4c8

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 KB

Contents

require 'spec/helper'
require 'innate/helper/cgi'

describe "url encode" do
  extend Innate::Helper::CGI

  it 'should url_encode strings' do
    # ok, I believe that the web is dumb for this
    # but this probably is a SHOULD thingy in the HTTP RFC
    url_encode('title with spaces').should == 'title+with+spaces'
    url_encode('[foo]').should == '%5Bfoo%5D'
    u('//').should == '%2F%2F'
  end
  it 'should url_decode strings' do
    url_decode('title%20with%20spaces').should == 'title with spaces'
    url_decode('title+with+spaces').should == 'title with spaces'
  end
  it 'should be reversible' do
    url_decode(u('../ etc/passwd')).should == '../ etc/passwd'
  end
end

describe 'html escape' do
  extend Innate::Helper::CGI

  it 'should escape html' do
    html_escape('& < >').should == '&amp; &lt; &gt;'
    h('<&>').should == '&lt;&amp;&gt;'
  end
  it 'should unescape html' do
    html_unescape('&lt; &amp; &gt;').should == '< & >'
  end
  it 'should be reversible' do
    html_unescape(html_escape('2 > b && b <= 0')).should == '2 > b && b <= 0'
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
manveru-innate-2009.02.06 spec/innate/helper/cgi.rb
manveru-innate-2009.02.21 spec/innate/helper/cgi.rb
manveru-innate-2009.02.25 spec/innate/helper/cgi.rb
manveru-innate-2009.03.24 spec/innate/helper/cgi.rb
manveru-innate-2009.04.01 spec/innate/helper/cgi.rb
manveru-innate-2009.04.08 spec/innate/helper/cgi.rb
manveru-innate-2009.04.18 spec/innate/helper/cgi.rb
manveru-innate-2009.04 spec/innate/helper/cgi.rb
manveru-innate-2009.05 spec/innate/helper/cgi.rb
manveru-innate-2009.06.12 spec/innate/helper/cgi.rb
manveru-innate-2009.06 spec/innate/helper/cgi.rb
rjspotter-innate-2009.06.29 spec/innate/helper/cgi.rb
rjspotter-innate-2009.06.30 spec/innate/helper/cgi.rb
rjspotter-innate-2009.06.31 spec/innate/helper/cgi.rb
innate-2009.05 spec/innate/helper/cgi.rb
innate-2009.04.12 spec/innate/helper/cgi.rb
innate-2009.04 spec/innate/helper/cgi.rb
innate-2009.06.12 spec/innate/helper/cgi.rb
innate-2009.06 spec/innate/helper/cgi.rb