rast 0.9.0 → 0.10.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
  SHA256:
3
- metadata.gz: a01ca8e5b6df7f97b5d6e2f02d01a8e3c9498e7550f1c63e68f12e3833790af2
4
- data.tar.gz: 06e8052ad3b7d09ddadb05ea5363a214b37421d84450c2c77fae1b6634fa9ecb
3
+ metadata.gz: adc034a3bca9cb4f89517b83daf17262d21b0cbc0d9ea3f34d461a3b85813019
4
+ data.tar.gz: 122e83c3b55aabace04a15e41d02fca0be55a3d6d37e67ffbbcd1eee38c4ec82
5
5
  SHA512:
6
- metadata.gz: 113fcc0c29f2467540d28b950f9d7a35ab07979e31eb77a38f9ac180074d81fd3e0e97867008fa9b9eab506126a76bffb35a0d415d25f3dc64cb8bfeb5110316
7
- data.tar.gz: 456a3286e1d90c80833a9af9269cd9c22a4f674496a6376199b2f0c2fa5a2b0901c9764c287ef5abbf44155ec877016486f2f4363e7d673fdf4deed30fabc232
6
+ metadata.gz: 619c067e5e697a676e699a8432149cd95206c5531307ce8a8a97b9e918a3829b1d228852d8520443e44d50e861f329199e2a3138fe3e4ee1f8f4f5a74ffe782e
7
+ data.tar.gz: 20b87b3f08e7813025091d092a49fe6af4bd9066cd7f6cb8eef144d99739c9c46e1301f28918f74ef30366818e585a98c690f3d8b8c5de25539fc1531413ce34
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Change log
2
2
 
3
+ - 0.10.0 - Optional variables definition for 1 to 1 rules.
3
4
  - 0.9.0 - execute return value is now the expected outcome (removed result method)
4
5
  - 0.8.1.pre - Allow spaces in rules.
5
6
  - 0.8.0.pre - Auto-detect variable type.
data/Gemfile CHANGED
@@ -11,9 +11,6 @@ group :test do
11
11
  gem 'lumberjack', '~> 1.0', '>= 1.0.13'
12
12
  gem 'rb-inotify', '~> 0.9.10'
13
13
 
14
- gem 'guard-rspec', require: false
15
- gem 'pry'
16
- gem 'pry-nav'
17
14
  gem 'rspec'
18
15
  gem 'simplecov', '~> 0.8.2'
19
16
  end
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
- # /* splitting input string into tokens */
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rast'
5
- spec.version = '0.9.0'
5
+ spec.version = '0.10.0'
6
6
  spec.authors = ['Royce Remulla']
7
7
  spec.email = ['royce.com@gmail.com']
8
8
 
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.9.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-04-30 00:00:00.000000000 Z
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
- - ".gitignore"
22
- - ".rspec"
23
- - ".rubocop.yml"
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.1.2
78
+ rubygems_version: 3.0.8
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: RSpec AST - All Scenario Testing