Sha256: e49621c34235ca98afa7508dece1cf69b2b7b39cd27fd140c33e484ac1700900

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

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

describe Spectate::Encode do
  include Spectate::Encode
  describe "encoding" do
    it "changes spaces to underscores" do
      encode("I am the very model of a modern Major General").should == "I_am_the_very_model_of_a_modern_Major_General"
    end
    
    it "changes underscores to double underscores" do
      encode("snake_case is too_cool").should == "snake__case_is_too__cool"
    end
    
    it "CGI-encodes everything else" do
      encode("2 + 1 is equal_to 5 & that's a fact!").should == "2_%2B_1_is_equal__to_5_%26_that%27s_a_fact%21"
    end
  end

  describe "decoding" do
    it "changes underscores to spaces" do
      decode("I_am_the_very_model_of_a_modern_Major_General").should == "I am the very model of a modern Major General"
    end
    
    it "changes double underscores to spaces" do
      decode("snake__case_is_too__cool").should == "snake_case is too_cool" 
    end
    
    it "CGI-encodes everything else" do
      decode("2_%2B_1_is_equal__to_5_%26_that%27s_a_fact%21").should == "2 + 1 is equal_to 5 & that's a fact!"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spectate-0.0.0 spec/encode_spec.rb