Sha256: d09092e7bd4547d6c06de33350957b539759a9a634f190638b0121963b92a1c7

Contents?: true

Size: 1019 Bytes

Versions: 189

Compression:

Stored size: 1019 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe WebMock::Util::JSON do
  describe ".parse" do
    it "should parse json without parsing dates" do
      expect(WebMock::Util::JSON.parse("\"a\":\"2011-01-01\"")).to eq(
        {"a" => "2011-01-01"}
      )
    end

    it "can parse json with multibyte characters" do
      expect(WebMock::Util::JSON.parse(
        "{\"name\":\"山田太郎\"\,\"job\":\"会社員\"}"
      )).to eq({"name" => "山田太郎", "job" => "会社員"})
    end

    it "rescues ArgumentError's from YAML.load" do
      allow(YAML).to receive(:load).and_raise(ArgumentError)
      expect {
        WebMock::Util::JSON.parse("Bad JSON")
      }.to raise_error WebMock::Util::JSON::ParseError
    end
  end

  describe ".convert_json_to_yaml" do
    it "parses multibyte characters" do
      expect(WebMock::Util::JSON.convert_json_to_yaml(
        "{\"name\":\"山田太郎\"\,\"job\":\"会社員\"}"
      )).to eq "{\"name\": \"山田太郎\", \"job\": \"会社員\"}"
    end
  end
end

Version data entries

189 entries across 180 versions & 12 rubygems

Version Path
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/webmock-3.18.1/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/unit/util/json_spec.rb
webmock-3.18.1 spec/unit/util/json_spec.rb