Sha256: 89bf27fa013de017c68c7564c2f0e17db7cdac4378496d267f7bac13221220dc

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'
require 'ronin/formatting/extensions/html/integer'

describe Integer do
  subject { 0x26 }

  it "should provide String#html_escape" do
    should respond_to(:html_escape)
  end

  it "should provide String#format_html" do
    should respond_to(:format_html)
  end

  it "should provide String#js_escape" do
    should respond_to(:js_escape)
  end

  it "should provide String#format_js" do
    should respond_to(:format_js)
  end

  describe "#html_escape" do
    let(:html_escaped) { "&" }

    it "should HTML escape itself" do
      expect(subject.html_escape).to eq(html_escaped)
    end
  end

  describe "#format_html" do
    let(:formatted_html) { "&" }

    it "should HTML format all chars" do
      expect(subject.format_html).to eq(formatted_html)
    end
  end

  describe "#js_escape" do
    let(:special_byte) { 0x0a }
    let(:escaped_special_byte) { '\n' }

    let(:normal_byte) { 0x41 }
    let(:normal_char) { 'A' }

    it "should escape special JavaScript characters" do
      expect(special_byte.js_escape).to eq(escaped_special_byte)
    end

    it "should ignore normal characters" do
      expect(normal_byte.js_escape).to eq(normal_char)
    end
  end

  describe "#format_js" do
    let(:js_escaped) { '\x26' }

    it "should JavaScript format ascii bytes" do
      expect(subject.format_js).to eq(js_escaped)
    end

    it "should JavaScript format unicode bytes" do
      expect(0xd556.format_js).to eq('\uD556')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-support-0.5.2 spec/formatting/html/integer_spec.rb