class RubyEventStore::RSpec::Matchers::ListPhraser
Public Class Methods
call(object)
click to toggle source
# File lib/ruby_event_store/rspec/matchers.rb, line 8 def call(object) items = Array(object).compact.map { |o| format(o) } return "" if items.empty? if items.one? items.join else "#{items[all_but_last].join(", ")} and #{items.fetch(-1)}" end end
Private Class Methods
all_but_last()
click to toggle source
# File lib/ruby_event_store/rspec/matchers.rb, line 20 def all_but_last (0...-1) end
format(object)
click to toggle source
# File lib/ruby_event_store/rspec/matchers.rb, line 24 def format(object) if object.respond_to?(:description) ::RSpec::Support::ObjectFormatter.format(object) else "be a #{object}" end end