Sha256: 6421b39978fec6e552ca537eeaf48fbe3b85c986fe5a8dd389bbc6a1131ca942

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

require "spec_helper"

describe Mixpal::Util do
  subject { described_class }

  describe ".hash_to_js_object_string" do
    it "converts a ruby hash to a string representation of a javascript object" do
      expect(subject.hash_to_js_object_string({key: "value", another: "more value"})).
        to eq "{\"key\": \"value\",\"another\": \"more value\"}"
    end

    it "leaves Booleans intact to be interpreted as JS Boolean" do
      expect(subject.hash_to_js_object_string({ is_cool: true })).
        to eq "{\"is_cool\": true}"
    end

    it "leaves Fixnums intact to be interpreted as JS Numbers" do
      expect(subject.hash_to_js_object_string({ age: 21 })).
        to eq "{\"age\": 21}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mixpal-0.0.4 spec/lib/mixpal/util_spec.rb