Module: Synthra::WebhookSimulator::GitHub

Defined in:
lib/synthra/webhook_simulator.rb

Overview

Simulate GitHub webhooks

Constant Summary collapse

EVENTS =
{
  push: "push",
  pull_request: "pull_request",
  issue: "issues",
  release: "release"
}.freeze

Class Method Summary collapse

Class Method Details

.pull_request(repo:, action: "opened", **options) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
# File 'lib/synthra/webhook_simulator.rb', line 327

def pull_request(repo:, action: "opened", **options)
  WebhookSimulator.send("pull_request", data: {
    action: action,
    number: rand(1..1000),
    repository: { full_name: repo },
    pull_request: {
      title: "Test PR",
      state: action == "closed" ? "closed" : "open"
    }
  }, **options)
end

.push(repo:, ref: "refs/heads/main", **options) ⇒ Object



318
319
320
321
322
323
324
325
# File 'lib/synthra/webhook_simulator.rb', line 318

def push(repo:, ref: "refs/heads/main", **options)
  WebhookSimulator.send("push", data: {
    ref: ref,
    repository: { full_name: repo },
    commits: [],
    pusher: { name: "user", email: "user@example.com" }
  }, **options)
end