Skip to content

Commit b1de334

Browse files
authored
Correctly pass arguments to a rake task (#1514)
1 parent c90e5cc commit b1de334

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

sentry-ruby/lib/sentry/rake.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class Task
2020
alias orig_execute execute
2121

2222
def execute(args=nil)
23-
return orig_execute unless Sentry.initialized? && Sentry.get_current_hub
23+
return orig_execute(args) unless Sentry.initialized? && Sentry.get_current_hub
2424

2525
Sentry.get_current_hub.with_background_worker_disabled do
26-
orig_execute
26+
orig_execute(args)
2727
end
2828
end
2929
end

sentry-ruby/spec/sentry/rake_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,16 @@
2424

2525
expect(message).not_to match(/Sentry/)
2626
end
27+
28+
it "run rake task with original arguments" do
29+
message = ""
30+
31+
# if we change the directory in the current process, it'll affect other tests that relies on system call too
32+
# e.g. release detection tests
33+
Thread.new do
34+
message = `cd spec/support && bundle exec rake pass_arguments[arguments]`
35+
end.join
36+
37+
expect(message).to match("arguments")
38+
end
2739
end

sentry-ruby/spec/support/Rakefile.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
Sentry.configuration.skip_rake_integration = true
1515
1/0
1616
end
17+
18+
task :pass_arguments, ['name'] do |_task, args|
19+
puts args[:name]
20+
end

0 commit comments

Comments
 (0)