Sha256: 27944d3a28c6a40b23f9655946116382542f61fb2886806554993c24f36dae80

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 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

5 entries across 5 versions & 3 rubygems

Version Path
rspec-instructure-1.3.3 lib/spec/matchers/pretty.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/lib/spec/matchers/pretty.rb
rspec-1.3.2 lib/spec/matchers/pretty.rb
rspec-1.3.1 lib/spec/matchers/pretty.rb
rspec-1.3.1.rc lib/spec/matchers/pretty.rb