lib/remarkable/messages.rb in remarkable-3.1.6 vs lib/remarkable/messages.rb in remarkable-3.1.7

- old
+ new

@@ -1,8 +1,8 @@ -module Remarkable - # Holds the methods required by rspec for each matcher plus a collection of - # helpers to deal with I18n. +module Remarkable + # Holds the methods required by rspec for each matcher plus a collection of + # helpers to deal with I18n. # module Messages # Provides a default description message. Overwrite it if needed. # By default it uses default i18n options, but without the subjects, which @@ -82,22 +82,22 @@ # def array_to_sentence(array, inspect=false, empty_default='') words_connector = Remarkable.t 'remarkable.core.helpers.words_connector' two_words_connector = Remarkable.t 'remarkable.core.helpers.two_words_connector' last_word_connector = Remarkable.t 'remarkable.core.helpers.last_word_connector' - - array.map!{|i| i.inspect} if inspect + array = array.map { |i| i.inspect } if inspect + case array.length when 0 empty_default when 1 array[0].to_s when 2 "#{array[0]}#{two_words_connector}#{array[1]}" else "#{array[0...-1].join(words_connector)}#{last_word_connector}#{array[-1]}" end - end + end end end