Skip to content

Commit 4e0152a

Browse files
authored
Merge pull request #1523 from manicmaniac/test-danger-launch-without-gitlab
Add test to ensure Danger runs without gitlab gem
2 parents bb3e856 + f624ece commit 4e0152a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spec/danger_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,27 @@
5959
expect(result).to be false
6060
end
6161
end
62+
63+
context "when danger-gitlab is not installed" do
64+
it "gracefully handles missing gitlab gem without raising LoadError" do
65+
# danger is already required in spec_helper.rb so we have to launch a new process.
66+
script = <<~RUBY
67+
# Emulate the environment that does not have gitlab gem.
68+
module Kernel
69+
alias original_require require
70+
71+
def require(name)
72+
raise LoadError, "cannot load such file -- gitlab" if name == "gitlab"
73+
74+
original_require(name)
75+
end
76+
end
77+
78+
require "danger"
79+
80+
Danger::Runner.run([])
81+
RUBY
82+
expect { system(RbConfig.ruby, "-e", script) }.not_to output(/LoadError/).to_stderr_from_any_process
83+
end
84+
end
6285
end

0 commit comments

Comments
 (0)