compendium 1.1.3.2 → 1.1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/compendium/param_types.rb +8 -0
- data/lib/compendium/report.rb +2 -0
- data/lib/compendium/version.rb +1 -1
- data/spec/params_spec.rb +21 -6
- data/spec/report_spec.rb +36 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YThkODFkMDI0MDhhNjY4MzE4MWVhODA4ZTkxOGQ3MDg2YzM4YmQzYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2M4NGEyMWUyZTA4MmM1NmMxZTQ5N2JlMTk4NDg3NDVmZTc4ZjM2OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTFmMTE3YWFlMGI4YjM1YTY5MzQ1ODY0NWJkNThkMGZjMTQ0MGMwYjY5NzM1
|
10
|
+
MDc0OWU2MDlmZGE5YzNlOTNhYjJiMDk2ZTY3NjA5Njc2NjU0YmRhNjE4OGE3
|
11
|
+
MjBjNGJmMmViOTI5MTVlODI5N2YyZTM1NTFkNGJiNjIwYzRhN2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDdjZmJiNDJhNDllZjQxMzc0YWQ4MWQ2NTY1NzBkOGVmY2M3ZmViOWZhZjM0
|
14
|
+
YmIxYzk0NzQ1NjAyNThjZDFjMzAyNzcxMTQyYzM3MzhkOGRkN2VhYWFlMDdh
|
15
|
+
YjlkMGRlZjNjODkzYTAwYmYwMTcwNGJiODQ1ZWNhNmYwYjZlZjc=
|
data/lib/compendium/report.rb
CHANGED
data/lib/compendium/version.rb
CHANGED
data/spec/params_spec.rb
CHANGED
@@ -8,6 +8,7 @@ describe Compendium::Params do
|
|
8
8
|
opts << Compendium::Option.new(name: :report_type, type: :radio, choices: [:big, :small])
|
9
9
|
opts << Compendium::Option.new(name: :boolean, type: :boolean)
|
10
10
|
opts << Compendium::Option.new(name: :another_boolean, type: :boolean)
|
11
|
+
opts << Compendium::Option.new(name: :number, type: :scalar)
|
11
12
|
opts
|
12
13
|
}
|
13
14
|
|
@@ -30,14 +31,28 @@ describe Compendium::Params do
|
|
30
31
|
|
31
32
|
describe "#validations" do
|
32
33
|
let(:report_class) { Class.new(described_class) }
|
33
|
-
subject { report_class.new({}, options) }
|
34
34
|
|
35
|
-
|
36
|
-
report_class.
|
37
|
-
|
35
|
+
context 'presence' do
|
36
|
+
subject { report_class.new({}, options) }
|
37
|
+
|
38
|
+
before do
|
39
|
+
report_class.validates :ending_on, presence: true
|
40
|
+
subject.valid?
|
41
|
+
end
|
42
|
+
|
43
|
+
it { should_not be_valid }
|
44
|
+
its('errors.keys') { should include :ending_on }
|
38
45
|
end
|
39
46
|
|
40
|
-
|
41
|
-
|
47
|
+
context 'numericality' do
|
48
|
+
subject { report_class.new({ number: 'abcd' }, options) }
|
49
|
+
before do
|
50
|
+
report_class.validates :number, numericality: true
|
51
|
+
subject.valid?
|
52
|
+
end
|
53
|
+
|
54
|
+
it { should_not be_valid }
|
55
|
+
its('errors.keys') { should include :number }
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
data/spec/report_spec.rb
CHANGED
@@ -222,20 +222,46 @@ describe Compendium::Report do
|
|
222
222
|
end
|
223
223
|
|
224
224
|
describe "#valid?" do
|
225
|
-
|
226
|
-
|
227
|
-
|
225
|
+
context 'built-in validations' do
|
226
|
+
let(:report_class) do
|
227
|
+
Class.new(described_class) do
|
228
|
+
option :id, :dropdown, choices: (0..10).to_a, validates: { presence: true }
|
229
|
+
end
|
228
230
|
end
|
229
|
-
end
|
230
231
|
|
231
|
-
|
232
|
-
|
233
|
-
|
232
|
+
it "should return true if there are no validation failures" do
|
233
|
+
r = report_class.new(id: 5)
|
234
|
+
r.should be_valid
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should return false if there are validation failures" do
|
238
|
+
r = report_class.new(id: nil)
|
239
|
+
r.should_not be_valid
|
240
|
+
r.errors.keys.should include :id
|
241
|
+
end
|
234
242
|
end
|
235
243
|
|
236
|
-
|
237
|
-
|
238
|
-
|
244
|
+
context 'custom validation' do
|
245
|
+
let(:report_class) do
|
246
|
+
Class.new(described_class) do
|
247
|
+
option :number, :scalar
|
248
|
+
|
249
|
+
validate do
|
250
|
+
errors.add(:number, :invalid_number) unless number.even?
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return true if there are no validation failures" do
|
256
|
+
r = report_class.new(number: 4)
|
257
|
+
r.should be_valid
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should return false if there are validation failures" do
|
261
|
+
r = report_class.new(number: 5)
|
262
|
+
r.should_not be_valid
|
263
|
+
r.errors.keys.should include :number
|
264
|
+
end
|
239
265
|
end
|
240
266
|
end
|
241
267
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compendium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.3.
|
4
|
+
version: 1.1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vandersluis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
type: :runtime
|