Sha256: b5d790ae998741a9a415c1faf637c994a0df3fa105343d804dd55ba8c29b07f7
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
# encoding: utf-8 module Hexx module RSpec # The utility sends multiline string to system # # Allows stubbing system calls in specifications. # # @example # System.call %( # inch --pedantic # rubocop # ) # # @api private class System < String # Initializes multiline text to be sent to system # # Removes repetitive spaces from itself # # @param [#to_s] _ # Multiline text to be sent to system # # @return [undefined] def initialize(_) super strip! gsub!(/ {2,}/, " ") end # Returns non-empty lines without trailing spaces # # @return [Array<String>] def lines Array(super) # Array() is needed to support rubies 1.9.3 .map(&:strip) .reject(&:empty?) end # Sends itself to system line by line # # @return [self] def call lines.each(&method(:system)) self end # Sends multiline string to system # # @example (see Hexx::RSpec::System) # # @param (see #initialize) # # @return [Hexx::RSpec::System] # utility object (allows chaining) def self.call(text) new(text).call end end # class System end # module RSpec end # module Hexx
Version data entries
10 entries across 10 versions & 1 rubygems