rast 0.9.0 → 0.10.0
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 +1 -0
- data/Gemfile +0 -3
- data/README.md +1 -0
- data/lib/rast/parameter_generator.rb +19 -1
- data/lib/rast/rules/rule_evaluator.rb +7 -2
- data/rast.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc034a3bca9cb4f89517b83daf17262d21b0cbc0d9ea3f34d461a3b85813019
|
4
|
+
data.tar.gz: 122e83c3b55aabace04a15e41d02fca0be55a3d6d37e67ffbbcd1eee38c4ec82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619c067e5e697a676e699a8432149cd95206c5531307ce8a8a97b9e918a3829b1d228852d8520443e44d50e861f329199e2a3138fe3e4ee1f8f4f5a74ffe782e
|
7
|
+
data.tar.gz: 20b87b3f08e7813025091d092a49fe6af4bd9066cd7f6cb8eef144d99739c9c46e1301f28918f74ef30366818e585a98c690f3d8b8c5de25539fc1531413ce34
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,7 @@ RSpec All Scenario Testing
|
|
11
11
|
`exemption/exclusions` - rule defining variable combinations to be excluded from the test.
|
12
12
|
`outcome` - the left portion of a rule e.g. `true: true&true`
|
13
13
|
`clause` - the right portion of a rule
|
14
|
+
`token` - used loosely to denote the individual variable in a rule. e.g. `true: you & me`, 'you' and 'me' are tokens.
|
14
15
|
|
15
16
|
|
16
17
|
##
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'pry'
|
4
3
|
require 'yaml'
|
5
4
|
require 'rast/rast_spec'
|
6
5
|
require 'rast/rules/rule'
|
@@ -80,7 +79,26 @@ class ParameterGenerator
|
|
80
79
|
param
|
81
80
|
end
|
82
81
|
|
82
|
+
# Detects if rule config has one outcome to one token mapping.
|
83
|
+
def one_to_one(outcome_to_clause)
|
84
|
+
outcome_to_clause.each do |outcome, clause|
|
85
|
+
return false if RuleEvaluator.tokenize(clause: clause).size > 1
|
86
|
+
end
|
87
|
+
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Used to optimize by detecting the variables if rules config is a 1 outcome to 1 rule token.
|
92
|
+
def detect_variables(spec_config)
|
93
|
+
return nil unless one_to_one(spec_config['rules'])
|
94
|
+
|
95
|
+
{ vars: spec_config['rules'].values }
|
96
|
+
end
|
97
|
+
|
83
98
|
def instantiate_spec(spec_config)
|
99
|
+
|
100
|
+
spec_config['variables'] = detect_variables(spec_config) if spec_config['variables'].nil?
|
101
|
+
|
84
102
|
spec = RastSpec.new(
|
85
103
|
description: spec_config[:description],
|
86
104
|
variables: spec_config['variables'],
|
@@ -56,8 +56,7 @@ class RuleEvaluator
|
|
56
56
|
@stack_operations.clear
|
57
57
|
@stack_rpn.clear
|
58
58
|
|
59
|
-
|
60
|
-
tokens = expression.split(RE_TOKENS).reject(&:empty?)
|
59
|
+
tokens = RuleEvaluator.tokenize(clause: expression)
|
61
60
|
|
62
61
|
# /* loop for handling each token - shunting-yard algorithm */
|
63
62
|
tokens.each { |token| shunt_internal(token: token.strip) }
|
@@ -66,6 +65,12 @@ class RuleEvaluator
|
|
66
65
|
@stack_rpn.reverse!
|
67
66
|
end
|
68
67
|
|
68
|
+
# splitting input string into tokens
|
69
|
+
# @ clause - rule clause to be tokenized
|
70
|
+
def self.tokenize(clause: '')
|
71
|
+
clause.to_s.split(RE_TOKENS).reject(&:empty?)
|
72
|
+
end
|
73
|
+
|
69
74
|
# /**
|
70
75
|
# * Evaluates once parsed math expression with "var" variable included.
|
71
76
|
# *
|
data/rast.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royce Remulla
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Extends RSpec functionality by using the catch-all-scenario testing (CAST)
|
14
14
|
principle.
|
@@ -18,9 +18,9 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
21
|
+
- .gitignore
|
22
|
+
- .rspec
|
23
|
+
- .rubocop.yml
|
24
24
|
- CHANGELOG.md
|
25
25
|
- Gemfile
|
26
26
|
- Gemfile.lock
|
@@ -66,16 +66,16 @@ require_paths:
|
|
66
66
|
- lib
|
67
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ~>
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '2.0'
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.0.8
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: RSpec AST - All Scenario Testing
|