module DangerSpecHelper

Public Class Methods

fake_danger() click to toggle source
# File lib/gitlab/dangerfiles/spec_helper.rb, line 30
def self.fake_danger
  Class.new do
    attr_reader :git, :gitlab, :helper

    # rubocop:disable Gitlab/ModuleWithInstanceVariables
    def initialize(git: nil, gitlab: nil, helper: nil)
      @git = git
      @gitlab = gitlab
      @helper = helper
    end

    # rubocop:enable Gitlab/ModuleWithInstanceVariables
  end
end
new(git: nil, gitlab: nil, helper: nil) click to toggle source

rubocop:disable Gitlab/ModuleWithInstanceVariables

# File lib/gitlab/dangerfiles/spec_helper.rb, line 35
def initialize(git: nil, gitlab: nil, helper: nil)
  @git = git
  @gitlab = gitlab
  @helper = helper
end
testing_dangerfile() click to toggle source

A stubbed out Dangerfile for use in tests

# File lib/gitlab/dangerfiles/spec_helper.rb, line 25
def self.testing_dangerfile
  env = Danger::EnvironmentManager.new(testing_env)
  Danger::Dangerfile.new(env, testing_ui)
end
testing_env() click to toggle source

Example environment (ENV) that would come from running a PR on TravisCI

# File lib/gitlab/dangerfiles/spec_helper.rb, line 15
def self.testing_env
  {
    "GITLAB_CI" => "true",
    "DANGER_GITLAB_HOST" => "gitlab.example.com",
    "CI_MERGE_REQUEST_IID" => 28_493,
    "DANGER_GITLAB_API_TOKEN" => "123sbdq54erfsd3422gdfio",
  }
end
testing_ui() click to toggle source

A silent version of the user interface

# File lib/gitlab/dangerfiles/spec_helper.rb, line 9
def self.testing_ui
  Cork::Board.new(silent: true)
end