assert 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/assert/factory.rb +10 -0
- data/lib/assert/version.rb +1 -1
- data/test/unit/factory_tests.rb +20 -0
- metadata +4 -4
data/lib/assert/factory.rb
CHANGED
@@ -60,6 +60,12 @@ module Assert
|
|
60
60
|
self.type_cast(Random.file_path_string, :string)
|
61
61
|
end
|
62
62
|
|
63
|
+
alias_method :path, :dir_path
|
64
|
+
|
65
|
+
def url(host = nil, length = nil)
|
66
|
+
self.type_cast(Random.url_string(host, length), :string)
|
67
|
+
end
|
68
|
+
|
63
69
|
def binary
|
64
70
|
self.type_cast(Random.binary, :binary)
|
65
71
|
end
|
@@ -136,6 +142,10 @@ module Assert
|
|
136
142
|
File.join(self.dir_path_string, self.file_name_string)
|
137
143
|
end
|
138
144
|
|
145
|
+
def self.url_string(host = nil, length = nil)
|
146
|
+
File.join(host.to_s, self.dir_path_string(length))
|
147
|
+
end
|
148
|
+
|
139
149
|
def self.binary
|
140
150
|
[ self.integer(10000) ].pack('N*')
|
141
151
|
end
|
data/lib/assert/version.rb
CHANGED
data/test/unit/factory_tests.rb
CHANGED
@@ -11,6 +11,7 @@ module Assert::Factory
|
|
11
11
|
should have_imeths :date, :time, :datetime
|
12
12
|
should have_imeths :string, :text, :slug, :hex
|
13
13
|
should have_imeths :file_name, :dir_path, :file_path
|
14
|
+
should have_imeths :path, :url
|
14
15
|
should have_imeths :binary, :boolean
|
15
16
|
should have_imeths :type_cast, :type_converter
|
16
17
|
|
@@ -110,6 +111,25 @@ module Assert::Factory
|
|
110
111
|
assert_match /\A[a-z]{6}\.[a-z]{3}\Z/, segments.last
|
111
112
|
end
|
112
113
|
|
114
|
+
should "return a random url string using `url`" do
|
115
|
+
u = subject.url
|
116
|
+
segments = u.split('/')
|
117
|
+
|
118
|
+
assert_kind_of String, u
|
119
|
+
assert_match /\A\//, u
|
120
|
+
assert_equal 4, segments.size
|
121
|
+
segments[1..-1].each{ |s| assert_match /\A[a-z]{4}\Z/, s }
|
122
|
+
end
|
123
|
+
|
124
|
+
should "allow passing a host string using `url`" do
|
125
|
+
host = "example.com"
|
126
|
+
assert_match /\A#{host}\//, subject.url(host)
|
127
|
+
end
|
128
|
+
|
129
|
+
should "allow passing a maximum length using `url`" do
|
130
|
+
assert_equal 2, subject.url('', 1).length # plus leading '/'
|
131
|
+
end
|
132
|
+
|
113
133
|
should "return a random binary string using `binary`" do
|
114
134
|
assert_kind_of String, subject.binary
|
115
135
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2014-
|
19
|
+
date: 2014-03-05 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
prerelease: false
|