Module: TestSuite

Defined in:
lib/test_suite.rb,
lib/test_suite/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.array?(actual) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/test_suite.rb', line 11

def array?(actual)
  puts actual.is_a?(Array) ? "Object is an array" : "Object is not an array"
  puts "Object: #{actual}"
end

.hash?(actual) ⇒ Boolean

object type

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/test_suite.rb', line 6

def hash?(actual)
  puts actual.is_a?(Hash) ? "Object is a hash" : "Object is not a hash"
  puts "Object: #{actual}"
end

.hash_empty?(actual) ⇒ Boolean

work with hashes

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/test_suite.rb', line 32

def hash_empty?(actual)
  puts actual.empty? ? "Hash is empty" : "Hash is not empty"
  puts "Hash: #{actual}"
end

.hash_has_two_keys?(actual) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
# File 'lib/test_suite.rb', line 44

def hash_has_two_keys?(actual)
  if actual.empty?
    puts "Hash is empty"
  else
    puts actual.size > 1 ? "Hash has 2 or more keys" : "Hash has one key"
    puts "Hash key(s): #{actual.keys}"
  end
end

.hash_value_greater_nil?(actual) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/test_suite.rb', line 37

def hash_value_greater_nil?(actual)
  arr = []
  actual.each_value { |val| arr << val if val > 0 }
  puts arr.size == actual.size ? "All hash values are greater than 0" : "Hash has value(s) equal/less than nil"
  puts "Hash value(s): #{actual.values}"
end

.number?(actual) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/test_suite.rb', line 16

def number?(actual)
  puts actual.is_a?(Numeric) ? "Object is a number" : "Object is not a number"
  puts "Object: #{actual}"
end

.str_to_arr(actual) ⇒ Object



70
71
72
73
# File 'lib/test_suite.rb', line 70

def str_to_arr(actual)
  puts "Object was converted to an array"
  puts "It is #{actual.split.inspect} now"
end

.string?(actual) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/test_suite.rb', line 21

def string?(actual)
  puts actual.is_a?(String) ? "Object is a string" : "Object is not a string"
  puts "Object: #{actual}"
end

.symbol?(actual) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/test_suite.rb', line 26

def symbol?(actual)
  puts actual.is_a?(Symbol) ? "Object is a symbol" : "Object is not a symbol"
  puts "Object: #{actual}"
end

.to_i(actual) ⇒ Object



59
60
61
62
# File 'lib/test_suite.rb', line 59

def to_i(actual)
  puts "Object was converted to numeric type"
  puts "It is #{actual.to_i} now"
end

.to_s(actual) ⇒ Object

object conversion



54
55
56
57
# File 'lib/test_suite.rb', line 54

def to_s(actual)
  puts "Object was converted to string type"
  puts "It is #{actual.to_s.inspect} now"
end

.to_sym(actual) ⇒ Object



64
65
66
67
68
# File 'lib/test_suite.rb', line 64

def to_sym(actual)
  actual = actual.to_s if actual.is_a?(Numeric)
  puts "Object was converted to symbol type"
  puts "It is #{actual.to_sym.inspect} now"
end