Sha256: 0637587d703ae846fda263167e805cedeee13898769438ae734b6dd4410aed82

Contents?: true

Size: 840 Bytes

Versions: 18

Compression:

Stored size: 840 Bytes

Contents

module Rspec
  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

18 entries across 18 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.8 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.7 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.6 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.5 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.4 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.3 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.2 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.beta.1 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a10 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a9 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a8 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a7 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a6 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a5 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a4 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a3 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a2 lib/rspec/matchers/pretty.rb
rspec-expectations-2.0.0.a1 lib/rspec/matchers/pretty.rb