Sha256: 5b08ef976f1530873012973243520780528ebf5f9e9b600631c11af042ad8a0c
Contents?: true
Size: 946 Bytes
Versions: 23
Compression:
Stored size: 946 Bytes
Contents
# frozen_string_literal: true require 'spec_helper' describe Praxis::Handlers::JSON do let(:dictionary) { { 'foo' => 1 } } let(:dictionary_json) { '{"foo":1}' } let(:array) { [1, 2, 3] } let(:array_json) { '[1,2,3]' } describe '#parse' do it 'handles dictionaries' do expect(subject.parse(dictionary_json)).to eq(dictionary) end it 'handles arrays' do expect(subject.parse(array_json)).to eq(array) end end # slightly cheesy: use #parse to test #generate by round-tripping everything describe '#generate' do it 'pretty-prints' do result = subject.generate({ 'foo' => 1 }) expect(result).to include("\n") expect(result).to match(/^ /m) end it 'handles dictionaries' do expect(subject.parse(subject.generate(dictionary))).to eq(dictionary) end it 'handles arrays' do expect(subject.parse(subject.generate(array))).to eq(array) end end end
Version data entries
23 entries across 23 versions & 1 rubygems