Sha256: 066ba4169b3b208f16c8b2b8a51ae86f760e87d64728dbd5a23978e4fc7c1f7e
Contents?: true
Size: 1.08 KB
Versions: 33
Compression:
Stored size: 1.08 KB
Contents
class RecordedEvent attr_reader :name, :data def initialize(name, data) @name = name.to_s @data = data end def inspect "<Event:#{name} #{inspect_data}>" end def ==(other) name == other.name && data == other.data end private def inspect_data data.inject([]) { |result, (key, value)| result << "#{key.inspect} => #{value.inspect.slice(0, 20)}" }.join(", ") end end class RecordingObserver attr_reader :events def initialize @events = [] end def method_missing(name, data) @events << RecordedEvent.new(name, data) end end RSpec::Matchers.define :notify_observers do |event_name, data| match do |ignored_subject| @event = RecordedEvent.new(event_name, data) recorder.events.should include(@event) end failure_message do "Expected event:\n#{@event.inspect}\n\nGot events:\n#{recorder.events.map(&:inspect).join("\n")}" end def recorder Saucy::Configuration.observers.last end end RSpec.configure do |config| config.before do Saucy::Configuration.observers = [RecordingObserver.new] end end
Version data entries
33 entries across 33 versions & 2 rubygems