discourse/spec/support
Loïc Guitaut 719457e430 DEV: Add a `try` step to services
This patch adds a new step to services named `try`.

It’s useful to rescue exceptions that some steps could raise. That way,
if an exception is caught, the service will stop its execution and can
be inspected like with any other steps.

Just wrap the steps that can raise with a `try` block:
```ruby
try do
  step :step_that_can_raise
  step :another_step_that_can_raise
end
```
By default, `try` will catch any exception inheriting from
`StandardError`, but we can specify what exceptions to catch:
```ruby
try(ArgumentError, RuntimeError) do
  step :will_raise
end
```

An outcome matcher has been added: `on_exceptions`. By default it will
be executed for any exception caught by the `try` step.
Here also, we can specify what exceptions to catch:
```ruby
on_exceptions(ArgumentError, RuntimeError) do |exception|
  …
end
```

Finally, an RSpec matcher has been added:
```ruby
  it { is_expected.to fail_with_exception }
  # or
  it { is_expected.to fail_with_exception(ArgumentError) }
```
2024-11-19 12:01:07 +01:00
..
locales DEV: Upgrade Rails to version 7.1 2024-07-04 10:58:21 +02:00
versioning
backups_helpers.rb DEV: Add backup helpers for specs (#28394) 2024-08-16 14:51:57 +10:00
bookmarkable_helper.rb
common_basic_reviewable_serializer.rb
concurrency.rb
diagnostics_helper.rb
discourse_event_helper.rb
dom_matcher.rb
fake_bookmark_hashtag_data_source.rb
fake_logger.rb DEV: Upgrade Rails to version 7.1 2024-07-04 10:58:21 +02:00
fake_s3.rb DEV: Fix missing require in `spec/support/fake_s3` (#27399) 2024-06-10 14:02:48 +08:00
fast_image_helpers.rb
final_destination_helper.rb
helpers.rb DEV: Track SQL queries from MiniSql (#28824) 2024-09-11 10:14:53 +03:00
i18n_helpers.rb DEV: Upgrade Rails to version 7.1 2024-07-04 10:58:21 +02:00
imap_helper.rb
integration_helpers.rb
match_html_matcher.rb
mock_git_importer.rb
negated_matcher.rb
omniauth_helpers.rb DEV: More system specs for signup/login (#27150) 2024-05-23 10:01:05 -03:00
onebox_helpers.rb DEV: Avoid instance variables in specs 2024-07-11 14:31:20 +02:00
problem_check_matcher.rb
rate_limit_matcher.rb
sample_plugin_site_settings.yml
service_matchers.rb DEV: Add a `try` step to services 2024-11-19 12:01:07 +01:00
shared_examples_for_custom_fields.rb
shared_examples_for_stats_cacheable.rb
sidekiq_helpers.rb
site_settings_helpers.rb
system_helpers.rb DEV: Overhaul devcontainer configuration (#28446) 2024-11-14 12:11:38 +00:00
test_second_factor_action.rb
time_matcher.rb
topic_guardian_can_see_consistency_check.rb
ts_vector_matcher.rb
uploads_helpers.rb FIX: Use dualstack S3 endpoint for direct uploads (#29611) 2024-11-07 11:06:39 +10:00
user_sidebar_serializer_attributes.rb
webauthn_integration_helpers.rb