Sha256: fc3d419c20144a8cc9b899a82c33af97c0005c1968163aa118b99082f163376b

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path('../../../helper', __FILE__)
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

18 entries across 18 versions & 2 rubygems

Version Path
innate-2023.01.06 spec/innate/helper/cgi.rb
innate-2015.10.28 spec/innate/helper/cgi.rb
manveru-innate-2009.07 spec/innate/helper/cgi.rb
innate-2013.02.21 spec/innate/helper/cgi.rb
innate-2013.02 spec/innate/helper/cgi.rb
innate-2012.12 spec/innate/helper/cgi.rb
innate-2012.03 spec/innate/helper/cgi.rb
innate-2011.12 spec/innate/helper/cgi.rb
innate-2011.10 spec/innate/helper/cgi.rb
innate-2011.04 spec/innate/helper/cgi.rb
innate-2011.01 spec/innate/helper/cgi.rb
innate-2010.07 spec/innate/helper/cgi.rb
innate-2010.06.18 spec/innate/helper/cgi.rb
innate-2010.04 spec/innate/helper/cgi.rb
innate-2010.03 spec/innate/helper/cgi.rb
innate-2010.01 spec/innate/helper/cgi.rb
innate-2009.10 spec/innate/helper/cgi.rb
innate-2009.07 spec/innate/helper/cgi.rb