Sha256: eb4f5a7fb956beadb362adc1c8272ca9b284c6d396850fa61308c10923daaf6f

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

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

module Vedeu
  describe JSONParser do
    let(:described_class)    { JSONParser }
    let(:described_instance) { described_class.new(json) }
    let(:subject)            { described_instance }
    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_instance.parse }

      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.24 test/lib/vedeu/support/json_parser_test.rb