Module: Noid::Rails::RSpec
- Defined in:
- lib/noid/rails/rspec.rb
Overview
Provides a test minter conforming to the ‘Noid::Rails::Minter` interface for use in unit tests. The test minter is faster and avoids unexpected interactions with cleanup code commonly runs in test suites (e.g. database cleanup).
Applications should reenable their production minter for integration tests when appropriate
Constant Summary collapse
Instance Method Summary collapse
-
#disable_production_minter!(test_minter: DEFAULT_TEST_MINTER) ⇒ void
Replaces the configured production minter with a test minter.
-
#enable_production_minter! ⇒ void
Re-enables the original configured minter.
Instance Method Details
#disable_production_minter!(test_minter: DEFAULT_TEST_MINTER) ⇒ void
This method returns an undefined value.
Replaces the configured production minter with a test minter.
42 43 44 45 46 47 48 49 50 |
# File 'lib/noid/rails/rspec.rb', line 42 def disable_production_minter!(test_minter: DEFAULT_TEST_MINTER) return nil if @original_minter @original_minter = Noid::Rails.config.minter_class Noid::Rails.configure do |noid_config| noid_config.minter_class = test_minter end end |
#enable_production_minter! ⇒ void
This method returns an undefined value.
Re-enables the original configured minter.
56 57 58 59 60 61 62 63 64 |
# File 'lib/noid/rails/rspec.rb', line 56 def enable_production_minter! return nil unless @original_minter Noid::Rails.configure do |noid_config| noid_config.minter_class = @original_minter end @original_minter = nil end |