Module: Assert::Factory
- Extended by:
- Factory
- Included in:
- Factory
- Defined in:
- lib/assert/factory.rb
Defined Under Namespace
Modules: Random, TypeConverter
Constant Summary
collapse
- DAYS_IN_A_YEAR =
365
- SECONDS_IN_DAY =
24 * 60 * 60
Instance Method Summary
collapse
Instance Method Details
#binary ⇒ Object
73
74
75
|
# File 'lib/assert/factory.rb', line 73
def binary
self.type_cast(Random.binary, :binary)
end
|
#boolean ⇒ Object
77
78
79
|
# File 'lib/assert/factory.rb', line 77
def boolean
self.type_cast(Random.integer.even?, :boolean)
end
|
#dir_path(length = nil) ⇒ Object
Also known as:
path
55
56
57
|
# File 'lib/assert/factory.rb', line 55
def dir_path(length = nil)
self.type_cast(Random.dir_path_string(length), :string)
end
|
#email(domain = nil, length = nil) ⇒ Object
69
70
71
|
# File 'lib/assert/factory.rb', line 69
def email(domain = nil, length = nil)
self.type_cast(Random.email_string(domain, length), :string)
end
|
#file_name(length = nil) ⇒ Object
51
52
53
|
# File 'lib/assert/factory.rb', line 51
def file_name(length = nil)
self.type_cast(Random.file_name_string(length), :string)
end
|
#file_path ⇒ Object
59
60
61
|
# File 'lib/assert/factory.rb', line 59
def file_path
self.type_cast(Random.file_path_string, :string)
end
|
#float(max = nil) ⇒ Object
13
14
15
|
# File 'lib/assert/factory.rb', line 13
def float(max = nil)
self.type_cast(Random.float(max), :float)
end
|
#hex(length = nil) ⇒ Object
47
48
49
|
# File 'lib/assert/factory.rb', line 47
def hex(length = nil)
self.type_cast(Random.hex_string(length), :string)
end
|
#integer(max = nil) ⇒ Object
9
10
11
|
# File 'lib/assert/factory.rb', line 9
def integer(max = nil)
self.type_cast(Random.integer(max), :integer)
end
|
#slug(length = nil) ⇒ Object
43
44
45
|
# File 'lib/assert/factory.rb', line 43
def slug(length = nil)
self.type_cast(Random.slug_string(length), :string)
end
|
#string(length = nil) ⇒ Object
35
36
37
|
# File 'lib/assert/factory.rb', line 35
def string(length = nil)
self.type_cast(Random.string(length), :string)
end
|
#text(length = nil) ⇒ Object
39
40
41
|
# File 'lib/assert/factory.rb', line 39
def text(length = nil)
self.type_cast(Random.string(length || 20), :string)
end
|
#type_cast(value, type) ⇒ Object
81
82
83
|
# File 'lib/assert/factory.rb', line 81
def type_cast(value, type)
self.type_converter.send(type, value)
end
|
#type_converter ⇒ Object
85
|
# File 'lib/assert/factory.rb', line 85
def type_converter; TypeConverter; end
|
#url(host = nil, length = nil) ⇒ Object
65
66
67
|
# File 'lib/assert/factory.rb', line 65
def url(host = nil, length = nil)
self.type_cast(Random.url_string(host, length), :string)
end
|