Sha256: 26c963e7f9246424ef4e58d8c28f52efab645e230f7b4b6c10f5388980ca1aac

Contents?: true

Size: 1.78 KB

Versions: 25

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

# Copyright (c) 2024 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'minitest/autorun'
require 'loog'
require_relative '../../lib/factbase'
require_relative '../../lib/factbase/to_json'

# Test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
# License:: MIT
class TestToJSON < Minitest::Test
  def test_simple_rendering
    fb = Factbase.new
    f = fb.insert
    f.foo = 42
    f.foo = 256
    to = Factbase::ToJSON.new(fb)
    json = JSON.parse(to.json)
    assert(42, json[0]['foo'][1])
  end

  def test_sort_keys
    fb = Factbase.new
    f = fb.insert
    f.c = 42
    f.b = 1
    f.a = 256
    json = Factbase::ToJSON.new(fb).json
    assert(json.include?('{"a":256,"b":1,"c":42}'), json)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
factbase-0.4.0 test/factbase/test_to_json.rb
factbase-0.3.0 test/factbase/test_to_json.rb
factbase-0.2.1 test/factbase/test_to_json.rb
factbase-0.2.0 test/factbase/test_to_json.rb
factbase-0.1.1 test/factbase/test_to_json.rb
factbase-0.1.0 test/factbase/test_to_json.rb
factbase-0.0.60 test/factbase/test_to_json.rb
factbase-0.0.59 test/factbase/test_to_json.rb
factbase-0.0.58 test/factbase/test_to_json.rb
factbase-0.0.57 test/factbase/test_to_json.rb
factbase-0.0.56 test/factbase/test_to_json.rb
factbase-0.0.55 test/factbase/test_to_json.rb
factbase-0.0.54 test/factbase/test_to_json.rb
factbase-0.0.53 test/factbase/test_to_json.rb
factbase-0.0.52 test/factbase/test_to_json.rb
factbase-0.0.51 test/factbase/test_to_json.rb
factbase-0.0.50 test/factbase/test_to_json.rb
factbase-0.0.49 test/factbase/test_to_json.rb
factbase-0.0.48 test/factbase/test_to_json.rb
factbase-0.0.47 test/factbase/test_to_json.rb