Sha256: 08c9d5436f909428bbf5fc3a7e73d38edcdb10c9845a160420f35d6a3fbc099a

Contents?: true

Size: 861 Bytes

Versions: 3

Compression:

Stored size: 861 Bytes

Contents

require_relative '../../../../test_helper'
require_relative '../../../../../lib/vedeu/support/parsing/json_parser'

module Vedeu
  describe JSONParser do
    let(:described_module) { JSONParser }
    let(:output)           { "{}" }

    describe '.parse' do
      let(:subject) { described_module.parse(output) }

      it 'returns a Hash' do
        subject.must_be_instance_of(Hash)
      end

      context 'when the JSON is valid' do
        let(:output) { File.read('test/support/json/int1_lin1_str1.json')}

        it 'returns a Hash' do
          subject.must_be_instance_of(Hash)
        end
      end

      context 'when the JSON is invalid' do
        let(:output) { "{}" }

        before { Oj.stubs(:load).raises(Oj::ParseError) }

        it 'returns a Hash' do
          subject.must_be_instance_of(Hash)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.30 test/lib/vedeu/support/parsing/json_parser_test.rb
vedeu-0.0.29 test/lib/vedeu/support/parsing/json_parser_test.rb
vedeu-0.0.28 test/lib/vedeu/support/parsing/json_parser_test.rb