Sha256: 7430c2a937ebc6e9a9867156ddb7de2aadef2238ea76fee2ace9bb25b11bd4c4

Contents?: true

Size: 839 Bytes

Versions: 33

Compression:

Stored size: 839 Bytes

Contents

module Spec
  module Matchers
    module Pretty
      def split_words(sym)
        sym.to_s.gsub(/_/,' ')
      end

      def to_sentence(words)
        words = words.map{|w| w.inspect}
        case words.length
          when 0
            ""
          when 1
            " #{words[0]}"
          when 2
            " #{words[0]} and #{words[1]}"
          else
            " #{words[0...-1].join(', ')}, and #{words[-1]}"
        end
      end

      def _pretty_print(array)
        result = ""
        array.each_with_index do |item, index|
          if index < (array.length - 2)
            result << "#{item.inspect}, "
          elsif index < (array.length - 1)
            result << "#{item.inspect} and "
          else
            result << "#{item.inspect}"
          end
        end
        result
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 9 rubygems

Version Path
rspec-1.3.0 lib/spec/matchers/pretty.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/lib/spec/matchers/pretty.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/lib/spec/matchers/pretty.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/lib/spec/matchers/pretty.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/lib/spec/matchers/pretty.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/lib/spec/matchers/pretty.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/lib/spec/matchers/pretty.rb
media-path-0.1.2 vendor/rspec/lib/spec/matchers/pretty.rb
simple-templater-0.0.1.3 vendor/rspec/lib/spec/matchers/pretty.rb
pupu-0.0.2.pre vendor/rspec/lib/spec/matchers/pretty.rb
media-path-0.1.1.pre vendor/rspec/lib/spec/matchers/pretty.rb
simple-templater-0.0.1.2 vendor/rspec/lib/spec/matchers/pretty.rb
media-path-0.1.1 vendor/rspec/lib/spec/matchers/pretty.rb
simple-templater-0.0.1.1 vendor/rspec/lib/spec/matchers/pretty.rb
pupu-0.0.2 vendor/rspec/lib/spec/matchers/pretty.rb
rango-0.0.6 vendor/rspec/lib/spec/matchers/pretty.rb
rango-0.1.pre vendor/rspec/lib/spec/matchers/pretty.rb
pupu-0.0.1 vendor/rspec/lib/spec/matchers/pretty.rb
media-path-0.1 vendor/rspec/lib/spec/matchers/pretty.rb
simple-templater-0.0.1 vendor/rspec/lib/spec/matchers/pretty.rb