Skip to content

Commit

Permalink
we need this
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieujobin committed Oct 30, 2023
1 parent 59409cd commit 468ae93
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
37 changes: 36 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 180`
# on 2023-10-30 03:34:16 UTC using RuboCop version 1.57.2.
# on 2023-10-30 03:57:18 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -21,6 +21,12 @@ Lint/AssignmentInCondition:
Exclude:
- 'lib/webhook_system/subscription.rb'

# Offense count: 3
# Configuration parameters: DebuggerMethods.
Lint/Debugger:
Exclude:
- 'spec/dispatching_events_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/RedundantDirGlobSort:
Expand All @@ -44,6 +50,13 @@ Naming/MethodParameterName:
Exclude:
- 'lib/webhook_system/encoder.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'spec/support/rails_seven_one.rb'

# Offense count: 9
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
Expand Down Expand Up @@ -163,6 +176,20 @@ Style/Documentation:
- 'lib/webhook_system/encoder.rb'
- 'lib/webhook_system/subscription_topic.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/MultilineIfModifier:
Exclude:
- 'spec/support/rails_seven_one.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Exclude:
- 'spec/support/rails_seven_one.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
Expand All @@ -182,3 +209,11 @@ Style/RedundantFreeze:
Style/RegexpLiteral:
Exclude:
- 'spec/dispatching_events_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Exclude:
- 'spec/support/rails_seven_one.rb'
6 changes: 5 additions & 1 deletion spec/dispatching_events_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

require 'spec_helper'
require 'minitest' # required for Rails 6.1
require 'minitest'
require 'byebug'

describe 'dispatching events', aggregate_failures: true, db: true do
let(:hook_url) { "http://lvh.me/hook1" }
Expand Down Expand Up @@ -73,6 +74,7 @@ def payload_attributes
error_message = "POST request to #{hook_url} failed with code: 400 and error I don't like you"
expect {
perform_enqueued_jobs do
debugger
expect {
WebhookSystem::Subscription.dispatch event
}.to raise_error(WebhookSystem::Job::RequestFailed, error_message)
Expand All @@ -93,10 +95,12 @@ def payload_attributes
let(:upstream_error) { %r{RuntimeError\nexception message\n} }

it 'fires the jobs' do
debugger
subscription1_hook_stub.to_raise(RuntimeError.new('exception message'))

error_message = /POST request to #{hook_url} failed with code: 0 and error .*RuntimeError.*/
expect {
debugger
perform_enqueued_jobs do
expect {
WebhookSystem::Subscription.dispatch event
Expand Down
22 changes: 22 additions & 0 deletions spec/support/rails_seven_one.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require "active_support/testing/assertions"

module ActiveSupport
module Testing
module Assertions
# Assertion that the block should not raise an exception.
#
# Passes if evaluated code in the yielded block raises no exception.
#
# assert_nothing_raised do
# perform_service(param: 'no_exception')
# end
def assert_nothing_raised
yield # .tap { debugger ; assert(true) }
rescue => error
raise Minitest::UnexpectedError.new(error)
end
end
end
end if Rails.version > '7.1'
1 change: 1 addition & 0 deletions webhook_system.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Gem::Specification.new do |gem|

gem.add_development_dependency 'bundler', '> 1.17', '< 2.6'
gem.add_development_dependency 'coveralls_reborn', '~> 0.25'
gem.add_development_dependency 'byebug'
gem.add_development_dependency 'simplecov-lcov'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec', '~> 3.0'
Expand Down

0 comments on commit 468ae93

Please sign in to comment.