spec_helpers.rb 451 B

123456789101112
  1. module SpecHelpers
  2. def build_events(options = {})
  3. options[:values].map.with_index do |tuple, index|
  4. event = Event.new
  5. event.agent = agents(:bob_weather_agent)
  6. event.payload = (options[:pattern] || {}).dup.merge((options[:keys].zip(tuple)).inject({}) { |memo, (key, value)| memo[key] = value; memo })
  7. event.created_at = (100 - index).hours.ago
  8. event.updated_at = (100 - index).hours.ago
  9. event
  10. end
  11. end
  12. end