RSpec::Matchers.define :contain_event do |expected|
  match do |events|
    events.select { |event| event.name.to_s == expected.to_s }.any?
  end
  failure_message_for_should do |events|
    "expected that #{event_names(events)} would contain an event with the name #{expected}"
  end
  failure_message_for_should_not do |events|
    "expected that #{event_names(events)} would not contain an event with the name #{expected}"
  end

  # Provide descriptive error message: [created, started_preparing]
  def event_names(events)
    '[' + events.map { |event| event.name}.join(', ') + ']'
  end
end
RSpec::Matchers.define :contain_event do |expected|
  match do |events|
    events.select { |event| event.name.to_s == expected.to_s }.any?
  end
  failure_message do |events|
    "expected that #{event_names(events)} would contain an event with the name #{expected}"
  end
  failure_message_when_negated do |events|
    "expected that #{event_names(events)} would not contain an event with the name #{expected}"
  end

  # Provide descriptive error message: [created, started_preparing]
  def event_names(events)
    '[' + events.map { |event| event.name}.join(', ') + ']'
  end
end
Convert specs to RSpec 3.4.4 syntax with Transpec
Convert specs to RSpec 3.4.4 syntax with Transpec

This conversion is done by Transpec 3.2.1 with the following command:
    transpec

* 1 conversion
    from: failure_message_for_should { }
      to: failure_message { }

* 1 conversion
    from: failure_message_for_should_not { }
      to: failure_message_when_negated { }

For more details: https://github.com/yujinakayama/transpec#supported-conversions
