Module: Pathway::Rspec::ListHelpers
- Included in:
- FieldListHelpers
- Defined in:
- lib/pathway/rspec/matchers/list_helpers.rb
Instance Method Summary collapse
- #as_list(items, **kwargs) ⇒ Object
- #as_sentence(items, connector: ', ', last_connector: ' and ') ⇒ Object
Instance Method Details
#as_list(items, **kwargs) ⇒ Object
6 7 8 |
# File 'lib/pathway/rspec/matchers/list_helpers.rb', line 6 def as_list(items, **kwargs) as_sentence(items.map(&:inspect), **kwargs) end |
#as_sentence(items, connector: ', ', last_connector: ' and ') ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/pathway/rspec/matchers/list_helpers.rb', line 10 def as_sentence(items, connector: ', ', last_connector: ' and ') *rest, last = items result = String.new result << rest.join(connector) << last_connector if rest.any? result << last end |