Sha256: cac652f2165ddf29431befc9453ea61c143aa3216e2cad1ee5a0378c5a90920c

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require File.expand_path("spec_helper", __dir__)

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

    describe "with Dangerfile" do
      before do
        @dangerfile = testing_dangerfile
        @iblinter = @dangerfile.iblinter

        # mock the PR data
        # you can then use this, eg. github.pr_author, later in the spec
        json = File.read(File.dirname(__FILE__) + "/support/fixtures/github_pr.json")
        allow(@iblinter.github).to receive(:pr_json).and_return(json)
      end

      it "inline comment works with relative path" do
        linter = IBLinterRunner.new("/path/to/binary")
        allow(linter).to receive(:lint) do
          JSON.parse(File.read(File.dirname(__FILE__) + "/support/fixtures/iblinter.json"))
        end
        allow(@iblinter).to receive(:iblinter).and_return(linter)
        allow(@iblinter).to receive(:iblinter_installed?).and_return(true)
        allow(Dir).to receive(:pwd).and_return("/home/projects")
        allow(File).to receive(:exist?).and_return(true)
        @iblinter.lint("/home/projects")
        errors = [
          Violation.new("Error message", false, "bar/File.xib", nil),
          Violation.new("Failed due to IBLinter errors", false, nil, nil)
        ]
        warnings = [
          Violation.new("Warning message", false, "foo/File.xib", nil)
        ]
        expect(@iblinter.violation_report[:errors]).to eq errors
        expect(@iblinter.violation_report[:warnings]).to eq warnings
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-iblinter-0.0.3 spec/plugin_spec.rb