Sha256: 30806050ccd053eeb3cd10621fb983f0944a10fe38a403c10d27686bbf683790

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

require 'spec_helper'

describe CMSScanner::Formatter::Json do

  it_behaves_like CMSScanner::Formatter::Buffer

  subject(:formatter) { described_class.new }
  let(:output_file)   { File.join(FIXTURES, 'output.txt') }

  before { formatter.views_directories << FIXTURES_VIEWS }

  describe '#format' do
    its(:format) { should eq 'json' }
  end

  describe '#output' do
    it 'puts the rendered text in the buffer' do
      2.times { formatter.output('@render_me', test: 'Working') }

      expect(formatter.buffer).to eq "\"test\": \"Working\",\n" * 2
    end
  end

  describe '#beautify' do
    it 'writes the buffer in the file' do
      2.times { formatter.output('@render_me', test: 'yolo') }

      expect($stdout).to receive(:puts).with(JSON.pretty_generate(JSON.parse('{"test": "yolo"}')))
      formatter.beautify
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cms_scanner-0.0.6 spec/app/formatters/json_spec.rb
cms_scanner-0.0.5 spec/app/formatters/json_spec.rb
cms_scanner-0.0.4 spec/app/formatters/json_spec.rb
cms_scanner-0.0.3 spec/app/formatters/json_spec.rb
cms_scanner-0.0.2 spec/app/formatters/json_spec.rb