Sha256: 0733368082b23a359a37b2f9ff201e526cb95fe205a2b9eada28f84b02bcfc42

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

require_relative "../spec_helper"

module SpaceCheckstyleReports::Entity
  FILE_NODE_SAMPLE_1 = <<NODE
<file
  name="/Users/ted3x/Workspace/sample/src/main/java/io/github/ted3x/Sample.java" >
  #{ERROR_NODE_SAMPLE_1}
</file>
NODE

  FILE_NODE_SAMPLE_2 = <<NODE
<file
  name="/Users/ted3x/Workspace/sample/src/test/java/io/github/ted3x/Sample2.java" >
  #{ERROR_NODE_SAMPLE_1}
  #{ERROR_NODE_SAMPLE_2}
</file>
NODE

  FILE_NODE_SAMPLE_EMPTY = <<NODE
<file
  name="/Users/ted3x/Workspace/sample/src/main/java/io/github/ted3x/Sample.java" />
NODE

  describe SpaceCheckstyleReports::Entity::FoundFile do
    let(:file) { FoundFile.new(REXML::Document.new(node).root, prefix: "/Users/ted3x/Workspace/sample") }

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

      it "should read it successfully" do
        expect(file.path).to eq("/Users/ted3x/Workspace/sample/src/main/java/io/github/ted3x/Sample.java")
        expect(file.errors.size).to eq(1)
        expect(file.relative_path).to eq("src/main/java/io/github/ted3x/Sample.java")
      end
    end

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

      it "should read it successfully" do
        expect(file.path).to eq("/Users/ted3x/Workspace/sample/src/test/java/io/github/ted3x/Sample2.java")
        expect(file.errors.size).to eq(2)
        expect(file.relative_path).to eq("src/test/java/io/github/ted3x/Sample2.java")
      end
    end

    context "sample empty" do
      let(:node) { FILE_NODE_SAMPLE_EMPTY }

      it "should read it successfully" do
        expect(file.path).to eq("/Users/ted3x/Workspace/sample/src/main/java/io/github/ted3x/Sample.java")
        expect(file.errors.size).to eq(0)
        expect(file.relative_path).to eq("src/main/java/io/github/ted3x/Sample.java")
      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_file_spec.rb