Module: Chewy::Minitest::Helpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/chewy/minitest/helpers.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#assert_indexes(index, strategy: :atomic, bypass_actual_index: true) ⇒ SearchIndexReceiver
Assert that an index changes during a block.
-
#run_indexing(strategy: :atomic) ⇒ Object
Run indexing for the database changes during the block provided.
Instance Method Details
#assert_indexes(index, strategy: :atomic, bypass_actual_index: true) ⇒ SearchIndexReceiver
Assert that an index changes during a block.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chewy/minitest/helpers.rb', line 17 def assert_indexes(index, strategy: :atomic, bypass_actual_index: true) type = Chewy.derive_type index receiver = SearchIndexReceiver.new bulk_method = type.method :bulk # Manually mocking #bulk because we need to properly capture `self` bulk_mock = lambda do |*bulk_args| receiver.catch bulk_args, self bulk_method.call(*bulk_args) unless bypass_actual_index {} end type.define_singleton_method :bulk, bulk_mock Chewy.strategy(strategy) do yield end type.define_singleton_method :bulk, bulk_method assert_includes receiver.updated_indexes, index, "Expected #{index} to be updated but it wasn't" receiver end |