much-factory 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/much-factory.rb +3 -2
- data/lib/much-factory/version.rb +1 -1
- data/test/unit/much-factory_tests.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b387fe94e2dabf5a5ab3984c5523ecd6b63c4187bb6a0c806924a33e934fa10
|
4
|
+
data.tar.gz: 9e515898f2148d7df486ec257f16aaa193d0f4e09b646577f837b18666508a97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fe55eed1841c17d93651ca81f129fcbea231821c537d22b416c3abbc7ea483b6ab16eda6a0c0167c52a5ab382cf22a431c98966366803a983b9f2d61ca7efd
|
7
|
+
data.tar.gz: 30f0f2d313000a701e5ec4ab65ef015173be0af72d7509810d1b565a29f5dd2f1f3c90eecf9ac104f187161930ef9040bfaaa58d77389044312197a47077cf22
|
data/lib/much-factory.rb
CHANGED
@@ -12,8 +12,9 @@ module MuchFactory
|
|
12
12
|
type_cast(Random.integer(max), :integer)
|
13
13
|
end
|
14
14
|
|
15
|
-
def float(max = nil)
|
16
|
-
|
15
|
+
def float(max = nil, precision: Factory.integer(5))
|
16
|
+
factor = (10 ** precision).to_f
|
17
|
+
(type_cast(Random.float(max), :float) * factor).round / factor
|
17
18
|
end
|
18
19
|
|
19
20
|
DAYS_IN_A_YEAR = 365
|
data/lib/much-factory/version.rb
CHANGED
@@ -39,6 +39,14 @@ module MuchFactory
|
|
39
39
|
assert_that(float).equals(0.0)
|
40
40
|
end
|
41
41
|
|
42
|
+
should "allow passing a precision using `float`" do
|
43
|
+
float = subject.float(2, precision: 2)
|
44
|
+
assert_that((float * 100).round / 100.0).equals(float)
|
45
|
+
|
46
|
+
float = subject.float(0, precision: 2)
|
47
|
+
assert_that(float).equals(0.00)
|
48
|
+
end
|
49
|
+
|
42
50
|
should "return a random date using `date`" do
|
43
51
|
assert_that(subject.date).is_kind_of(Date)
|
44
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: much-factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: assert
|