Sha256: 983af1fc60fea4e0e1a6fc5bf4f84a18181cbe2195a3cedc5f1bb306c8b1dead

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
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

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-3.2.0 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-3.1.3 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-3.1.2 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-3.1.1 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-3.1.0 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-3.0.0 test/lib/rubycritic/generators/json_report_test.rb
rubycritic-2.9.4 test/lib/rubycritic/generators/json_report_test.rb