Module: RailsStuff::TestHelpers
- Extended by:
- TestHelpers
- Included in:
- TestHelpers
- Defined in:
- lib/rails_stuff/test_helpers.rb,
lib/rails_stuff/test_helpers/response.rb,
lib/rails_stuff/test_helpers/concurrency.rb,
lib/rails_stuff/test_helpers/integration_session.rb
Overview
Collection of RSpec configurations and helpers for better experience.
Defined Under Namespace
Modules: Concurrency, IntegrationSession, Response
Instance Method Summary collapse
-
#big_decimal ⇒ Object
Make BigDecimal`s more readable.
-
#i18n ⇒ Object
Raise all translation errors, to not miss any of translations.
- #setup(only: nil, except: nil) ⇒ Object
-
#thread ⇒ Object
Raise errors from failed threads.
Instance Method Details
#big_decimal ⇒ Object
Make BigDecimal`s more readable.
27 28 29 30 31 32 33 |
# File 'lib/rails_stuff/test_helpers.rb', line 27 def big_decimal require 'bigdecimal' BigDecimal.class_eval do alias_method :inspect_orig, :inspect alias_method :inspect, :to_s end end |
#i18n ⇒ Object
Raise all translation errors, to not miss any of translations. Make sure to set ‘config.action_view.raise_on_missing_translations = true` in `config/environments/test.rb` yourself.
43 44 45 46 47 48 |
# File 'lib/rails_stuff/test_helpers.rb', line 43 def i18n return unless defined?(I18n) I18n.config.exception_handler = ->(exception, _locale, _key, ) do raise exception.respond_to?(:to_exception) ? exception.to_exception : exception end end |
#setup(only: nil, except: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails_stuff/test_helpers.rb', line 8 def setup(only: nil, except: nil) items = instance_methods.map(&:to_s) - %w[setup] items -= Array.wrap(except).map(&:to_s) if except if only only = Array.wrap(only).map(&:to_s) items &= only items += only end items.each { |item| public_send(item) } end |
#thread ⇒ Object
Raise errors from failed threads.
36 37 38 |
# File 'lib/rails_stuff/test_helpers.rb', line 36 def thread Thread.abort_on_exception = true end |