Sha256: f6f555f4340c0b4945b700b14bd5ff020d664be81ef7c7c1e3176381e915c3ba

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

require_relative "setup"
require "ryo/json"
require "fileutils"

RSpec.describe Ryo::JSON do
  describe ".from_json_file" do
    subject(:ryo) { described_class.from_json_file(path, object:) }
    before { File.binwrite path, JSON.dump(x: 20, y: 40) }
    after { FileUtils.rm(path) }
    let(:path) { File.join(__dir__, "test.json") }

    context "with Ryo::Object" do
      let(:object) { Ryo::Object }
      it { is_expected.to be_instance_of(Ryo::Object) }
      it { is_expected.to eq("x" => 20, "y" => 40) }
    end

    context "with Ryo::BasicObject" do
      let(:object) { Ryo::BasicObject }
      it { expect(Ryo::BasicObject === ryo).to be(true) }
      it { is_expected.to eq("x" => 20, "y" => 40) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ryo.rb-0.5.2 spec/ryo_json_spec.rb
ryo.rb-0.5.1 spec/ryo_json_spec.rb
ryo.rb-0.5.0 spec/ryo_json_spec.rb