rspec-be_valid_when_matcher 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13656a0df980e172da9d2631a45796fa485a2d7d
4
- data.tar.gz: 482b5359c69d5dd445dc76bf8398e790dbd3d052
3
+ metadata.gz: 9b80bc4ac78d86e5f92bf0c2c58d6ca855c97b6b
4
+ data.tar.gz: 62559b46e1d71150a641fbd6ea6e5ba041da44b3
5
5
  SHA512:
6
- metadata.gz: cfb78ff406e455eac5b817f0f5e534585696b4910fdc483fd9896b099d10133a4727d24ea1655aa9f4b16b1b0908d24623108240a670dab74739db82b6d23256
7
- data.tar.gz: a3612cc0e19bbf3c89fbcb5ccef24f91f43a8df8f6f85b65d3aff2ad2be230920fe9fedf8ec7c3ba703206fb32002fd4e2430c2d556167649375fb5017412054
6
+ metadata.gz: 3e7c4e9d13002ca86fd4a15e99749dd0c433c5655d11d6a88ac4c87904c50c59b0d040e0fd660beb7ad2a4fde1045edb4315053279741a007b618890351eb1b5
7
+ data.tar.gz: 772dd5127e54b55e287de053e827a37a44666a5d88a4b0bde164bd062a2f35a97f6d49f0e4405db605a1cf7ea1cd0fab0455e9c98956b1e59a47230023c8236f
data/README.md CHANGED
@@ -130,6 +130,7 @@ be_valid_when(:field).is_regexp # Defaults to /^value$/
130
130
  be_valid_when(:field).is_array # Defaults to [42]
131
131
  be_valid_when(:field).is_hash # Defaults to { value: 42 }
132
132
  be_valid_when(:field).is_symbol # Defaults to :value
133
+ be_valid_when(:field).is_range # Defaults to 2..42
133
134
  ```
134
135
 
135
136
  ### Boolean values
@@ -121,7 +121,8 @@ module RSpec
121
121
  regexp: { value: /^value$/, type: Regexp },
122
122
  array: { value: [42], type: Array },
123
123
  hash: { value: { value: 42 }, type: Hash },
124
- symbol: { value: :value, type: Symbol } }.each do |name, properties|
124
+ symbol: { value: :value, type: Symbol },
125
+ range: { value: 2..42, type: Range } }.each do |name, properties|
125
126
  define_method "is_#{name}" do |value = properties[:value]|
126
127
  fail ArgumentError, "should be #{name}" unless value.is_a? properties[:type]
127
128
 
@@ -334,6 +335,13 @@ module RSpec
334
335
  # it { is_expected.to be_valid_when(:field).is_symbol }
335
336
  # @return [self]
336
337
 
338
+ # @!method is_range(value = 2..42)
339
+ # Setup matcher for checking range values.
340
+ # @raise [ArgumentError] if given non `Range` value.
341
+ # @example
342
+ # it { is_expected.to be_valid_when(:field).is_range }
343
+ # @return [self]
344
+
337
345
  # @!endgroup
338
346
 
339
347
  # @!group Logical value
@@ -1,114 +1,119 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------------------------ | ------ | --------------- |
3
- ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:1] | passed | 0.06734 seconds |
4
- ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:2] | passed | 0.0011 seconds |
5
- ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:3] | passed | 0.00339 seconds |
6
- ./spec/rspec/be_valid_when/is_spec.rb[1:1] | passed | 0.0002 seconds |
7
- ./spec/rspec/be_valid_when/is_spec.rb[1:2:1] | passed | 0.00402 seconds |
8
- ./spec/rspec/be_valid_when/is_spec.rb[1:3:1] | passed | 0.00282 seconds |
9
- ./spec/rspec/be_valid_when/is_spec.rb[1:3:2] | passed | 0.00144 seconds |
10
- ./spec/rspec/be_valid_when/is_spec.rb[1:4] | passed | 0.00012 seconds |
11
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:1:1] | passed | 0.01073 seconds |
12
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:1:2] | passed | 0.00014 seconds |
13
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:1] | passed | 0.01301 seconds |
14
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:2] | passed | 0.00014 seconds |
15
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:3] | passed | 0.00021 seconds |
16
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:1:1] | passed | 0.01034 seconds |
17
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:1:2] | passed | 0.00018 seconds |
18
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:1] | passed | 0.01086 seconds |
19
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:2] | passed | 0.00012 seconds |
20
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:3] | passed | 0.00025 seconds |
21
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:1:1] | passed | 0.01053 seconds |
22
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:1:2] | passed | 0.00013 seconds |
23
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:1] | passed | 0.01085 seconds |
24
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:2] | passed | 0.00014 seconds |
25
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:3] | passed | 0.00166 seconds |
26
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:1:1] | passed | 0.01278 seconds |
27
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:1:2] | passed | 0.00017 seconds |
28
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:1] | passed | 0.01238 seconds |
29
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:2] | passed | 0.00014 seconds |
30
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:3] | passed | 0.00027 seconds |
31
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:1:1] | passed | 0.01061 seconds |
32
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:1:2] | passed | 0.00014 seconds |
33
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:1] | passed | 0.01152 seconds |
34
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:2] | passed | 0.00016 seconds |
35
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:3] | passed | 0.00028 seconds |
36
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:1:1] | passed | 0.03119 seconds |
37
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:1:2] | passed | 0.00024 seconds |
38
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:1] | passed | 0.02242 seconds |
39
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:2] | passed | 0.00044 seconds |
40
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:3] | passed | 0.00055 seconds |
41
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:1:1] | passed | 0.01312 seconds |
42
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:1:2] | passed | 0.00016 seconds |
43
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:1] | passed | 0.01436 seconds |
44
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:2] | passed | 0.00019 seconds |
45
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:3] | passed | 0.00032 seconds |
46
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:1:1] | passed | 0.01014 seconds |
47
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:1:2] | passed | 0.00018 seconds |
48
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:2:1] | passed | 0.01334 seconds |
49
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:2:2] | passed | 0.00016 seconds |
3
+ ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:1] | passed | 0.00512 seconds |
4
+ ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:2] | passed | 0.00014 seconds |
5
+ ./spec/rspec/be_valid_when/is_not_present_spec.rb[1:3] | passed | 0.00026 seconds |
6
+ ./spec/rspec/be_valid_when/is_spec.rb[1:1] | passed | 0.00012 seconds |
7
+ ./spec/rspec/be_valid_when/is_spec.rb[1:2:1] | passed | 0.00255 seconds |
8
+ ./spec/rspec/be_valid_when/is_spec.rb[1:3:1] | passed | 0.00422 seconds |
9
+ ./spec/rspec/be_valid_when/is_spec.rb[1:3:2] | passed | 0.00088 seconds |
10
+ ./spec/rspec/be_valid_when/is_spec.rb[1:4] | passed | 0.00009 seconds |
11
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:1:1] | passed | 0.01004 seconds |
12
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:1:2] | passed | 0.00012 seconds |
13
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:1] | passed | 0.01104 seconds |
14
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:2] | passed | 0.00012 seconds |
15
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:1:2:3] | passed | 0.0002 seconds |
16
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:1:1] | passed | 0.01205 seconds |
17
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:1:2] | passed | 0.0002 seconds |
18
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:1] | passed | 0.04928 seconds |
19
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:2] | passed | 0.00059 seconds |
20
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:2:2:3] | passed | 0.00118 seconds |
21
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:1:1] | passed | 0.01121 seconds |
22
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:1:2] | passed | 0.00012 seconds |
23
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:1] | passed | 0.01146 seconds |
24
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:2] | passed | 0.00012 seconds |
25
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:3:2:3] | passed | 0.0003 seconds |
26
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:1:1] | passed | 0.01026 seconds |
27
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:1:2] | passed | 0.00019 seconds |
28
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:1] | passed | 0.01105 seconds |
29
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:2] | passed | 0.00017 seconds |
30
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:4:2:3] | passed | 0.00028 seconds |
31
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:1:1] | passed | 0.0119 seconds |
32
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:1:2] | passed | 0.00019 seconds |
33
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:1] | passed | 0.01206 seconds |
34
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:2] | passed | 0.00013 seconds |
35
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:5:2:3] | passed | 0.00033 seconds |
36
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:1:1] | passed | 0.0105 seconds |
37
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:1:2] | passed | 0.00013 seconds |
38
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:1] | passed | 0.01807 seconds |
39
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:2] | passed | 0.00024 seconds |
40
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:6:2:3] | passed | 0.00029 seconds |
41
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:1:1] | passed | 0.01052 seconds |
42
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:1:2] | passed | 0.00011 seconds |
43
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:1] | passed | 0.01054 seconds |
44
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:2] | passed | 0.00013 seconds |
45
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:7:2:3] | passed | 0.00028 seconds |
46
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:1:1] | passed | 0.01328 seconds |
47
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:1:2] | passed | 0.00014 seconds |
48
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:2:1] | passed | 0.0119 seconds |
49
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:2:2] | passed | 0.00017 seconds |
50
50
  ./spec/rspec/be_valid_when/is_type_spec.rb[1:8:2:3] | passed | 0.0003 seconds |
51
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:1:1] | passed | 0.01742 seconds |
52
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:1:2] | passed | 0.00022 seconds |
53
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:1] | passed | 0.02064 seconds |
54
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:2] | passed | 0.00023 seconds |
55
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:3] | passed | 0.00048 seconds |
56
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:1:1] | passed | 0.01379 seconds |
57
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:1:2] | passed | 0.00018 seconds |
58
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:1] | passed | 0.01777 seconds |
59
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:2] | passed | 0.00016 seconds |
60
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:3] | passed | 0.00031 seconds |
61
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:1:1] | passed | 0.01228 seconds |
62
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:1:2] | passed | 0.00019 seconds |
63
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:1] | passed | 0.01506 seconds |
64
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:2] | passed | 0.00012 seconds |
65
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:3] | passed | 0.00035 seconds |
66
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:1:1] | passed | 0.01902 seconds |
67
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:1:2] | passed | 0.00023 seconds |
68
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:1] | passed | 0.01763 seconds |
69
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:2] | passed | 0.00021 seconds |
70
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:3] | passed | 0.00043 seconds |
71
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:1:1] | passed | 0.01543 seconds |
72
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:1:2] | passed | 0.00019 seconds |
73
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:1] | passed | 0.01743 seconds |
74
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:2] | passed | 0.00018 seconds |
75
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:3] | passed | 0.00039 seconds |
76
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:1] | passed | 0.01322 seconds |
77
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:2] | passed | 0.00015 seconds |
78
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:15:1] | passed | 0.01135 seconds |
79
- ./spec/rspec/be_valid_when/is_type_spec.rb[1:15:2] | passed | 0.00012 seconds |
80
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:1] | passed | 0.0003 seconds |
81
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:2] | passed | 0.00066 seconds |
51
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:1:1] | passed | 0.01025 seconds |
52
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:1:2] | passed | 0.00013 seconds |
53
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:1] | passed | 0.01052 seconds |
54
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:2] | passed | 0.00014 seconds |
55
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:9:2:3] | passed | 0.00027 seconds |
56
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:1:1] | passed | 0.01105 seconds |
57
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:1:2] | passed | 0.00012 seconds |
58
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:1] | passed | 0.01259 seconds |
59
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:2] | passed | 0.00034 seconds |
60
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:10:2:3] | passed | 0.00075 seconds |
61
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:1:1] | passed | 0.01138 seconds |
62
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:1:2] | passed | 0.00014 seconds |
63
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:1] | passed | 0.01297 seconds |
64
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:2] | passed | 0.00013 seconds |
65
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:11:2:3] | passed | 0.00031 seconds |
66
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:1:1] | passed | 0.01115 seconds |
67
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:1:2] | passed | 0.00032 seconds |
68
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:1] | passed | 0.01137 seconds |
69
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:2] | passed | 0.00013 seconds |
70
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:12:2:3] | passed | 0.00027 seconds |
71
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:1:1] | passed | 0.01206 seconds |
72
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:1:2] | passed | 0.00015 seconds |
73
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:1] | passed | 0.01847 seconds |
74
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:2] | passed | 0.00014 seconds |
75
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:13:2:3] | passed | 0.00028 seconds |
76
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:1:1] | passed | 0.01124 seconds |
77
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:1:2] | passed | 0.00014 seconds |
78
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:2:1] | passed | 0.01155 seconds |
79
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:2:2] | passed | 0.00013 seconds |
80
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:14:2:3] | passed | 0.00031 seconds |
81
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:15:1] | passed | 0.01496 seconds |
82
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:15:2] | passed | 0.00014 seconds |
83
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:16:1] | passed | 0.01273 seconds |
84
+ ./spec/rspec/be_valid_when/is_type_spec.rb[1:16:2] | passed | 0.00018 seconds |
85
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:1] | passed | 0.00028 seconds |
86
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:2] | passed | 0.00008 seconds |
82
87
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:3] | passed | 0.00009 seconds |
83
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:4] | passed | 0.00008 seconds |
84
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:5] | passed | 0.00008 seconds |
85
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:6] | passed | 0.0001 seconds |
86
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:7] | passed | 0.00009 seconds |
87
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:8] | passed | 0.0001 seconds |
88
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:9] | passed | 0.00008 seconds |
88
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:4] | passed | 0.00067 seconds |
89
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:5] | passed | 0.0001 seconds |
90
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:6] | passed | 0.00008 seconds |
91
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:7] | passed | 0.0001 seconds |
92
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:8] | passed | 0.00008 seconds |
93
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:9] | passed | 0.00009 seconds |
89
94
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:1:10] | passed | 0.00008 seconds |
90
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:1] | passed | 0.00011 seconds |
91
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:2] | passed | 0.00012 seconds |
92
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:1] | passed | 0.0001 seconds |
93
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:2] | passed | 0.00014 seconds |
95
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:1] | passed | 0.00009 seconds |
96
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:2] | passed | 0.00013 seconds |
97
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:1] | passed | 0.00011 seconds |
98
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:2] | passed | 0.00011 seconds |
94
99
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:3] | passed | 0.0001 seconds |
95
100
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:4] | passed | 0.00012 seconds |
96
101
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:2:3:5] | passed | 0.0001 seconds |
97
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:1] | passed | 0.0001 seconds |
98
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:2:1] | passed | 0.00077 seconds |
99
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:2:2] | passed | 0.00078 seconds |
100
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:4:1] | passed | 0.0001 seconds |
101
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:4:2:1] | passed | 0.00101 seconds |
102
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:1] | passed | 0.00009 seconds |
103
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:2:1] | passed | 0.00081 seconds |
104
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:3:2:2] | passed | 0.00085 seconds |
105
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:4:1] | passed | 0.00011 seconds |
106
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:4:2:1] | passed | 0.00088 seconds |
102
107
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:4:2:2] | passed | 0.00082 seconds |
103
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:5] | passed | 0.0001 seconds |
104
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:1] | passed | 0.00013 seconds |
105
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:2] | passed | 0.00014 seconds |
108
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:5] | passed | 0.00011 seconds |
109
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:1] | passed | 0.00015 seconds |
110
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:2] | passed | 0.00015 seconds |
106
111
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:3] | passed | 0.00011 seconds |
107
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:4] | passed | 0.0001 seconds |
108
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:1:1] | passed | 0.00077 seconds |
109
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:1:2] | passed | 0.00202 seconds |
112
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:6:4] | passed | 0.00013 seconds |
113
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:1:1] | passed | 0.00082 seconds |
114
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:1:2] | passed | 0.00213 seconds |
110
115
  ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:2:1] | passed | 0.00078 seconds |
111
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:2:2] | passed | 0.00209 seconds |
112
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:8:1] | passed | 0.00089 seconds |
113
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:8:2:1] | passed | 0.0009 seconds |
114
- ./spec/rspec/be_valid_when_matcher_spec.rb[1:9:1] | passed | 0.00016 seconds |
116
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:7:2:2] | passed | 0.00212 seconds |
117
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:8:1] | passed | 0.00085 seconds |
118
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:8:2:1] | passed | 0.00083 seconds |
119
+ ./spec/rspec/be_valid_when_matcher_spec.rb[1:9:1] | passed | 0.00012 seconds |
@@ -7,7 +7,7 @@ class FakeModelFoo
7
7
  include ActiveModel::Validations
8
8
 
9
9
  [Numeric, Integer, Fixnum, Bignum, Float, Complex, Rational, BigDecimal,
10
- String, Regexp, Array, Hash, Symbol, TrueClass, FalseClass].each do |type|
10
+ String, Regexp, Array, Hash, Symbol, TrueClass, FalseClass, Range].each do |type|
11
11
  type_name = type.name.downcase
12
12
  field_name = "#{type_name}_field"
13
13
  not_field_name = "not_#{field_name}"
@@ -40,6 +40,7 @@ class FakeModelFoo
40
40
  validate :symbol_field_cannot_be_short
41
41
  validate :trueclass_field_cannot_be_false
42
42
  validate :falseclass_field_cannot_be_true
43
+ validate :range_field_cannot_be_empty
43
44
 
44
45
  def regexp_field_cannot_be_empty
45
46
  errors.add(:regexp_field, "can't be empty") if regexp_field.inspect.length < 3
@@ -64,6 +65,10 @@ class FakeModelFoo
64
65
  def falseclass_field_cannot_be_true
65
66
  errors.add(:falseclass_field, "can't be true") if falseclass_field == true
66
67
  end
68
+
69
+ def range_field_cannot_be_empty
70
+ errors.add(:range_field, "can't be negative") if !range_field.nil? && range_field.min < 0
71
+ end
67
72
  end
68
73
 
69
74
  describe 'be_valid_when' do
@@ -72,7 +77,7 @@ describe 'be_valid_when' do
72
77
  def invalid_values_for(type_name)
73
78
  { integer: 42, bignum: 42**42, float: 3.14, complex: 42.to_c, rational: 42.to_r,
74
79
  bigdecimal: BigDecimal.new('42'), string: 'value', regexp: /^value$/, array: [1, 2],
75
- hash: {}, symbol: :value
80
+ hash: {}, symbol: :value, range: 2..42
76
81
  }.reject do |key|
77
82
  if type_name.is_a? Symbol
78
83
  key == type_name
@@ -176,6 +181,13 @@ describe 'be_valid_when' do
176
181
  no_arguments: /^be valid when #symbol_field is a symbol \(:value\)$/,
177
182
  one_argument: /^be valid when #symbol_field is a symbol \(:some_symbol\)$/
178
183
  }
184
+ },
185
+ range: {
186
+ argument: { passing: 1..2, failing: -3..4 },
187
+ description: {
188
+ no_arguments: /^be valid when #range_field is a range \(2..42\)$/,
189
+ one_argument: /^be valid when #range_field is a range \(1..2\)$/
190
+ }
179
191
  }
180
192
  }.each do |name, props|
181
193
  method_name = "is_#{name}".to_sym
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-be_valid_when_matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Tuchowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -85,13 +85,13 @@ signing_key:
85
85
  specification_version: 4
86
86
  summary: RSpec be_valid_when matcher for ActiveRecord models.
87
87
  test_files:
88
+ - spec/examples.cache
89
+ - spec/support/takes_no_arguments.rb
90
+ - spec/support/returns_proper_results.rb
91
+ - spec/support/has_correct_description.rb
88
92
  - spec/spec_helper.rb
89
- - spec/rspec/be_valid_when_matcher_spec.rb
93
+ - spec/rspec/be_valid_when/is_type_spec.rb
90
94
  - spec/rspec/be_valid_when/is_spec.rb
91
95
  - spec/rspec/be_valid_when/is_not_present_spec.rb
92
- - spec/rspec/be_valid_when/is_type_spec.rb
93
- - spec/support/returns_proper_results.rb
94
- - spec/support/has_correct_description.rb
95
- - spec/support/takes_no_arguments.rb
96
- - spec/examples.cache
96
+ - spec/rspec/be_valid_when_matcher_spec.rb
97
97
  has_rdoc: