Module: Elastics::RSpec
- Defined in:
- lib/elastics/rspec.rb
Class Method Summary collapse
-
.configure(config, tag = :elastics) ⇒ Object
Adds around filter to perform elastics specific helper actions.
Class Method Details
.configure(config, tag = :elastics) ⇒ Object
Adds around filter to perform elastics specific helper actions.
- Enables autorefresh for each example,
- Executes `clear_elastics` before each example,
- Performs migration (once, for first occured example).
Filter is applied only to tagged examples (‘:elastics` by default).
RSpec.configure do |config|
Elastics::RSpec.configure(config)
end
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/elastics/rspec.rb', line 16 def configure(config, tag = :elastics) migrated = false error = nil config.around tag => true do |ex| if migrated raise error if error Model.list.each(&:clear_elastics) else begin Tasks.drop_indices Tasks.migrate rescue Error => e error = e raise e ensure migrated = true end end AutoRefresh.enable! { ex.run } end end |