Sha256: 60486de5e254e58da5e7a5dde1cd9110e4b39d15be0b2315d09e38fce7edefe2

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'
require 'rubycritic/core/analysed_modules_collection'
require 'rubycritic/generators/json_report'
require 'json'
require 'fakefs/safe'

describe RubyCritic::Generator::JsonReport do
  describe '#generate_report' do
    before(:each) do
      FakeFS.activate!
      create_analysed_modules_collection
      generate_report
    end

    after(:each) { FakeFS.deactivate! }

    it 'creates a report.json file' do
      assert File.file?('test/samples/report.json'), 'expected report.json file to be created'
    end

    it 'report file has data inside' do
      data = File.read('test/samples/report.json')
      assert data != '', 'expected report file not to be empty'
    end
  end

  def create_analysed_modules_collection
    @analysed_modules_collection = RubyCritic::AnalysedModulesCollection.new('test/samples/')
    RubyCritic::Config.root = 'test/samples'
  end

  def generate_report
    report = RubyCritic::Generator::JsonReport.new(@analysed_modules_collection)
    report.generate_report
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-2.9.3 test/lib/rubycritic/generators/json_report_test.rb