Skip to content

Instantly share code, notes, and snippets.

@dvdplm
dvdplm / mock_tire.rb
Created March 27, 2012 11:06
Mocking helper to stop Tire from submitting searches to Elasticsearch
module Tire
module Disable
module ClassMethods
def mock_es_response_doc
@mock_es_response_doc ||=
'{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 0,"max_score": null,"hits": []}}'
end
def enable! &blk
old_enabled = @tire_enabled || false