Sha256: 20d585a42a11be489c85ce8ed16910f6cb5b72997b8a8c8aad3c427e4f93f691

Contents?: true

Size: 584 Bytes

Versions: 20

Compression:

Stored size: 584 Bytes

Contents

require 'spec_helper'

describe "Riddle" do
  it "should escape characters correctly" do
    invalid_chars = ['(', ')', '|', '-', '!', '@', '~', '"', '/']
    invalid_chars.each do |char|
      base = "string with '#{char}' character"
      Riddle.escape(base).should == base.gsub(char, "\\#{char}")
    end
    
    # Not sure why this doesn't work within the loop...
    Riddle.escape("string with & character").should == "string with \\& character"
    
    all_chars = invalid_chars.join('') + '&'
    Riddle.escape(all_chars).should == "\\(\\)\\|\\-\\!\\@\\~\\\"\\/\\&"
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
riddle-2.1.0 spec/unit/riddle_spec.rb
riddle-2.0.0 spec/unit/riddle_spec.rb
riddle-1.5.12 spec/unit/riddle_spec.rb
riddle-1.5.11 spec/unit/riddle_spec.rb
riddle-1.5.10 spec/unit/riddle_spec.rb
riddle-1.5.9 spec/unit/riddle_spec.rb
riddle-1.5.8 spec/unit/riddle_spec.rb
riddle-1.5.7 spec/unit/riddle_spec.rb
riddle-1.5.6 spec/unit/riddle_spec.rb
riddle-1.5.5 spec/unit/riddle_spec.rb
riddle-1.5.4 spec/unit/riddle_spec.rb
riddle-1.5.3 spec/unit/riddle_spec.rb
riddle-1.5.2 spec/unit/riddle_spec.rb
riddle-1.5.1 spec/unit/riddle_spec.rb
riddle-1.5.0 spec/unit/riddle_spec.rb
riddle-1.4.0 spec/unit/riddle_spec.rb
riddle-1.3.3 spec/unit/riddle_spec.rb
riddle-1.3.2 spec/unit/riddle_spec.rb
riddle-1.3.1 spec/unit/riddle_spec.rb
riddle-1.3.0 spec/unit/riddle_spec.rb