Sha256: 19605a64e7d7d26f747a587d1a323dc30926871615f0ddf570a2004fe16b4226

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

require 'spec_helper'

describe Mulder::Formats::JSON do

  describe '#stream' do
    it 'defaults to STDOUT' do
      formatter = described_class.new(anything)
      expect(formatter.stream).to eq(STDOUT)
    end

    it 'returns the given stream' do
      io = mock()
      formatter = described_class.new(anything)
      formatter.stream = io

      expect(formatter.stream).to eq(io)
    end
  end

  describe '#output' do
    it 'prints json encoded output to the stream' do
      instances = [{ foo: :bar }]
      mocked_instances = mock(collect: instances)

      io = StringIO.new()
      formatter = described_class.new(mocked_instances)
      formatter.stream = io

      formatter.output
      expect(io.string).to eq('[{"foo":"bar"}]')
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mulder-0.4.0 spec/lib/mulder/formats/json_spec.rb
mulder-0.3.2 spec/lib/mulder/formats/json_spec.rb