Sha256: 97badae732599ead0ca0e16c855d40983f5d34acc3b4e9124642ac81db563f83
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
require 'km' require 'fileutils' require 'accept' class KM class << self public :log_name, :reset, :log end end def __(*args) file_this_included_from = caller.first.split(":").first app_root = File.expand_path(File.dirname(file_this_included_from)) args = [app_root]+args File.expand_path(File.join(args)) end class Helper def self.accept(cmd) c = TCPSocket.new('localhost', 9292) c.puts cmd.to_s return JSON.parse(c.read) rescue nil end def self.history accept :history end def self.clear accept :clear end def self.exit accept :exit end end class String def sort self.split('').sort.join('') end def sort! replace(self.sort) end end RSpec::Matchers.define :have_query_string do |expected| match do |value| expected.sort == value.sort end failure_message_for_should do |value| "expected #{value.inspect} to match #{expected.inspect}" end end #======================================# #= contain_string =# #======================================# # Check if a string has another string. Usage: # some_string.should contain("my string") RSpec::Matchers.define :contain_string do |needle| match do |haystack| haystack.index(needle) ? true : false end end class Hash def indifferent Hash.new { |hash,key| hash[key.to_s] if key.class == Symbol }.merge(self) end end def write_log(type, content) KM.instance_eval { @log_dir = __('log') } log_name = KM.send :log_name, type File.open(log_name, 'w+') do |fh| fh.puts content end end accept = Accept.new
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
km-1.3.0 | spec/setup.rb |
km-1.1.3 | spec/setup.rb |
km-1.1.2 | spec/setup.rb |
km-1.1.1 | spec/setup.rb |