Sha256: ef3017a67e0bc42105282b25360755bd38b361ef2122a791f398f38ae4ddb39d

Contents?: true

Size: 380 Bytes

Versions: 23

Compression:

Stored size: 380 Bytes

Contents

module Pathway
  module Rspec
    module ListHelpers
      def as_list(items)
        as_sentence(items.map(&:inspect))
      end

      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
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pathway-0.10.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.9.1 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.9.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.8.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.7.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.6.2 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.6.1 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.6.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.5.1 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.5.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.4.0 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.20 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.19 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.18 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.17 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.16 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.15 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.14 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.13 lib/pathway/rspec/matchers/list_helpers.rb
pathway-0.0.12 lib/pathway/rspec/matchers/list_helpers.rb