Sha256: cf754d6f5f756f43d73d9eafadfa8883b410c31aed3dccba2cc3db707bf394bf

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require_relative '../../../test_helper'

module Vedeu
  describe JSONParser do
    let(:described_class)    { JSONParser }
    let(:subject)            { described_class.new(json) }
    let(:json)               { "[]" }

    it 'returns a JSONParser instance' do
      subject.must_be_instance_of(JSONParser)
    end

    it 'sets an instance variable' do
      subject.instance_variable_get("@json").must_equal(json)
    end

    context 'when the instance variable is nil' do
      let(:json) {}

      it 'set the instance variable to empty string' do
        subject.instance_variable_get("@json").must_equal('')
      end
    end

    describe '#parse' do
      let(:subject) { described_class.parse(json) }

      context 'when the JSON contains a single interface' do
        let(:json) { File.read('test/support/single_interface.json') }

        it 'returns a Composition instance' do
          subject.must_be_instance_of(Buffer::Composition)
        end
      end

      context 'when the JSON contains multiple interfaces' do
        let(:json) { File.read('test/support/multi_interface.json') }

        it 'returns a Composition instance' do
          subject.must_be_instance_of(Buffer::Composition)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.25 test/lib/vedeu/support/json_parser_test.rb