Sha256: 9dcb8916f1650a1703fbb200a982a1b3de2bfa95d3fb84e54ac34be099d8d493

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'fileutils'

module RuboCop
  module Formatter
    describe HTMLFormatter, :isolated_environment do
      spec_root = File.expand_path('../../..', __FILE__)

      around do |example|
        project_path = File.join(spec_root, 'fixtures/html_formatter/project')
        FileUtils.cp_r(project_path, '.')

        Dir.chdir(File.basename(project_path)) do
          example.run
        end
      end

      let(:actual_html_path) do
        path = File.expand_path('result.html')
        CLI.new.run(['--format', 'html', '--out', path])
        path
      end

      let(:actual_html) do
        File.read(actual_html_path, encoding: 'UTF-8')
      end

      let(:expected_html_path) do
        File.join(spec_root, 'fixtures/html_formatter/expected.html')
      end

      let(:expected_html) do
        html = File.read(expected_html_path, encoding: 'UTF-8')
        # Avoid failure on version bump
        html.sub(/(class="version".{0,20})\d+(?:\.\d+){2}/i) do
          Regexp.last_match(1) + RuboCop::Version::STRING
        end
      end

      it 'outputs the result in HTML' do
        # FileUtils.copy(actual_html_path, expected_html_path)
        expect(actual_html).to eq(expected_html)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.29.1 spec/rubocop/formatter/html_formatter_spec.rb
rubocop-0.29.0 spec/rubocop/formatter/html_formatter_spec.rb
rubocop-0.28.0 spec/rubocop/formatter/html_formatter_spec.rb
rubocop-0.27.1 spec/rubocop/formatter/html_formatter_spec.rb
rubocop-0.27.0 spec/rubocop/formatter/html_formatter_spec.rb