Module: RSpec::TagMatchers::Helpers::SentenceHelper
- Included in:
- RSpec::TagMatchers::HasDateSelect, RSpec::TagMatchers::HasTag
- Defined in:
- lib/rspec/tag_matchers/helpers/sentence_helper.rb
Instance Method Summary collapse
-
#make_sentence(*strings) ⇒ String
Joins multiple strings into a sentence with punctuation and conjunctions.
Instance Method Details
#make_sentence(*strings) ⇒ String
Joins multiple strings into a sentence with punctuation and conjunctions.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rspec/tag_matchers/helpers/sentence_helper.rb', line 20 def make_sentence(*strings) = strings.last.is_a?(Hash) ? strings.pop : {} strings = strings.flatten.map(&:to_s).reject(&:empty?) conjunction = [:conjunction] || "and" case strings.count when 0 "" when 1 strings.first else last = strings.pop puncuation = strings.count > 1 ? ", " : " " [strings, "#{conjunction} #{last}"].flatten.join(puncuation) end end |