Sha256: 564732b6f63912cbaba855d3daef72c47e26268620ee1527d62229f132613e5f

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require_relative "../spec_helper"

module SpaceCheckstyleReports::Entity
  ERROR_NODE_SAMPLE_1 = <<NODE
<error
  line="144"
  column="108"
  severity="error"
  message="&apos;+&apos; should be on a new line."
  source="com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck"
/>
NODE

  ERROR_NODE_SAMPLE_2 = <<NODE
<error
  line="296"
  severity="error"
  message="Line has trailing spaces."
  source="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck"
/>
NODE

  describe SpaceCheckstyleReports::Entity::FoundError do
    let(:error) { FoundError.new(REXML::Document.new(node).root) }

    context "sample1" do
      let(:node) { ERROR_NODE_SAMPLE_1 }

      it "should read it successfully" do
        expect(error.line_number).to eq(144)
        expect(error.column_number).to eq(108)
        expect(error.severity).to eq("error")
        expect(error.html_unescaped_message).to eq("'+' should be on a new line.")
        expect(error.source).to eq("com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck")
      end
    end

    context "sample2" do
      let(:node) { ERROR_NODE_SAMPLE_2 }

      it "should read it successfully" do
        expect(error.line_number).to eq(296)
        expect(error.column_number).to be_nil
        expect(error.severity).to eq("error")
        expect(error.html_unescaped_message).to eq("Line has trailing spaces.")
        expect(error.source).to eq("com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-space_checkstyle_reports-1.0.1 spec/entity/found_error_spec.rb