Sha256: 72b995c09529029fec291c6588ffce7629d6f1b4aeaf921f52e999d415f75730

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require File.expand_path("spec_helper", __dir__)

module Danger
  describe Danger::DangerResharperInspectcode do
    it "should be a plugin" do
      expect(Danger::DangerResharperInspectcode.new(nil)).to be_a Danger::Plugin
    end

    describe "Report Parser Test" do
      before do
        require_relative "../lib/resharper_inspectcode/report_parser"
      end

      it "Parse report.xml" do
        report = ReportParser.parse_report_xml("spec/fixtures/report.xml")
        expect(report.first).to(
          eq Issue.new("MatsuriHime/Ho.cs", "14-47", 2, "Matsuri Hime is very cute.")
        )
        expect(report.select { |item| item.file == "Tsumugi/Nanyaine.cs" }.first).to(
          eq Issue.new("Tsumugi/Nanyaine.cs", "18-47", 1, "Nanyaine, is this!?")
        )
      end
    end

    describe "with Dangerfile" do
      before do
        @dangerfile = testing_dangerfile
        @my_plugin = @dangerfile.resharper_inspectcode
      end

      it "Parse XML report file with plugin" do
        @my_plugin.base_path = __dir__
        @my_plugin.report("fixtures/report.xml")
        expect(@my_plugin.violation_report[:warnings][0]).to(
          eq Violation.new("Matsuri Hime is very cute.", false, "MatsuriHime/Ho.cs", 2)
        )
        expect(@my_plugin.violation_report[:warnings][2]).to(
          eq Violation.new("Nanyaine, is this!?", false, "Tsumugi/Nanyaine.cs", 1)
        )
      end

      it "Throw Exception when report file not found" do
        @my_plugin.base_path = "/hogehagefuga/"
        expect { @my_plugin.report("hogedir/hogehoge.xml") }.to raise_error(Exception, /No report file was found at/)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danger-resharper_inspectcode-1.0.2 spec/resharper_inspectcode_spec.rb
danger-resharper_inspectcode-1.0.1 spec/resharper_inspectcode_spec.rb