rast 0.6.2.pre → 0.8.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/examples/triple.rb +15 -0
- data/lib/rast/parameter_generator.rb +26 -5
- data/lib/rast/spec_dsl.rb +6 -1
- data/rast.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c19a33dffcdb0b41b2e820aa28d087b54a37a1973a4a8bac78f0c4ab69f92316
|
4
|
+
data.tar.gz: f04d91004beec821be368a559e8944df6316502f71223d1314441304ce046cf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9ccd1ca66e2a9f4c3c8814bac0839bb808ea608b6b55de543ed46ea436f5f4f4ba9835026c26e3ce7586222233680c4c2d0ff0d29f96bdba0fa17c5bd5b7f92
|
7
|
+
data.tar.gz: e04a6581b873ed8b820bae2bf149ffab342196277af08c2328d6c89195ba8713c3ee5a91b84d084e70ed39e67edcdbb9a2c6331440eca1cc21237f7295bd545a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
- 0.8.0.pre - Auto-detect variable type.
|
4
|
+
- 0.7.0.pre - Display exclusion rule in the report
|
3
5
|
- 0.6.2.pre - Bugfix for 1D array of numbers scenario.
|
4
6
|
- 0.6.1.pre - Bugfix on the converters when used with rule exclusion.
|
5
7
|
- 0.6.0.pre - Reverted redesign.
|
data/examples/triple.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Triple. This example is used to test automatic detection of variable data type in yaml.
|
4
|
+
#
|
5
|
+
# @author Royce Remulla
|
6
|
+
#
|
7
|
+
class Triple
|
8
|
+
# Perform logical AND operation on two arguments.
|
9
|
+
#
|
10
|
+
# @param argument1 first argument of Boolean type.
|
11
|
+
# @param argument2 second argument of Boolean type.
|
12
|
+
def triple(argument1, argument2, _argument3)
|
13
|
+
argument1 && argument2
|
14
|
+
end
|
15
|
+
end
|
@@ -90,19 +90,40 @@ class ParameterGenerator
|
|
90
90
|
pair_config = spec_config['pair']
|
91
91
|
spec.init_pair(pair_config: pair_config) unless pair_config.nil?
|
92
92
|
|
93
|
-
|
93
|
+
unless spec_config['exclude'].nil?
|
94
|
+
spec.init_exclusion(spec_config['exclude'])
|
95
|
+
end
|
94
96
|
|
95
|
-
|
97
|
+
converters_config = spec_config['converters']
|
98
|
+
converters = if converters_config.nil?
|
99
|
+
# when no converters defined, we detect if type is consistent, otherwise assume it's string.
|
96
100
|
str_converter = StrConverter.new
|
97
|
-
spec_config['variables'].map
|
98
|
-
|
101
|
+
spec_config['variables'].map do |_key, array|
|
102
|
+
if same_data_type(array)
|
103
|
+
RuleEvaluator::DEFAULT_CONVERT_HASH[array.first.class]
|
104
|
+
else
|
105
|
+
str_converter
|
106
|
+
end
|
107
|
+
end
|
108
|
+
elsif converters_config.first.class == String
|
109
|
+
# when converters defined, determined by the converter name as String.
|
99
110
|
spec_config['converters'].map do |converter|
|
100
111
|
Object.const_get(converter).new
|
101
112
|
end
|
102
113
|
else
|
103
|
-
|
114
|
+
# converters defined, probably programmatically when yaml-less, just return it.
|
115
|
+
converters_config
|
104
116
|
end
|
105
117
|
|
106
118
|
spec.init_converters(converters: converters)
|
107
119
|
end
|
120
|
+
|
121
|
+
def same_data_type(array)
|
122
|
+
type = array.first.class
|
123
|
+
array.each do |element|
|
124
|
+
return false if element.class != type &&
|
125
|
+
![FalseClass, TrueClass].include?(element.class)
|
126
|
+
end
|
127
|
+
true
|
128
|
+
end
|
108
129
|
end
|
data/lib/rast/spec_dsl.rb
CHANGED
@@ -106,7 +106,12 @@ class SpecDSL
|
|
106
106
|
|
107
107
|
def generate_rspecs
|
108
108
|
main_scope = self
|
109
|
-
|
109
|
+
|
110
|
+
title = "#{@subject_name}: #{@fixtures.first[:spec].description}"
|
111
|
+
exclusion = fixtures.first[:spec].exclude_clause
|
112
|
+
title += ", Excluded: '#{exclusion}'" if exclusion
|
113
|
+
|
114
|
+
RSpec.describe title do
|
110
115
|
main_scope.fixtures.each do |fixture|
|
111
116
|
generate_rspec(
|
112
117
|
scope: main_scope,
|
data/rast.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royce Remulla
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- examples/positive.rb
|
35
35
|
- examples/prime_number.rb
|
36
36
|
- examples/recruiter.rb
|
37
|
+
- examples/triple.rb
|
37
38
|
- examples/worker.rb
|
38
39
|
- lib/rast.rb
|
39
40
|
- lib/rast/assert.rb
|