rast 0.1.0.pre → 0.1.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +2 -5
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +10 -9
- data/lib/rast/parameter_generator.rb +11 -9
- data/lib/rast/rast_spec.rb +7 -5
- data/lib/rast/rules/logic_helper.rb +3 -3
- data/lib/rast/rules/rule_evaluator.rb +5 -4
- data/lib/rast/rules/rule_processor.rb +1 -1
- data/lib/rast/rules/rule_validator.rb +1 -1
- data/lib/rast/spec_dsl.rb +10 -3
- data/lib/rast.rb +2 -2
- data/rast.gemspec +5 -8
- metadata +12 -11
- data/lib/rast/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
---
|
2
|
-
SHA256:
|
3
|
-
metadata.gz: eb63e35c4439e5fc90b4e25ce9981739f624a114d6f8848eb07576eac93e9222
|
4
|
-
data.tar.gz: 12f0b43bd2385dada9e6272e8895054911c3bee8fbe2ff267914ceae996f5a82
|
5
2
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27a95910bf913315b1188d751aaabefe976ebcc78ae8f827fdc71d5ca8d0ff162e3a0fa2af20abdccaf1ba8d5ba62d6cc2f9b470c3b38c05198c6e8a0109b6f4
|
4
|
+
data.tar.gz: 9704f5073764d040472332937b435d5156b6457309d5ab08cbe0b6eb1c2d79f2b523fd00e391fc5eec7ae95ce0a4428b1f1805b4ed43a1e9ee8275d732eb9627
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
coderay (1.1.2)
|
5
5
|
diff-lcs (1.3)
|
6
|
-
docile (1.
|
6
|
+
docile (1.1.5)
|
7
7
|
ffi (1.12.2)
|
8
8
|
formatador (0.2.5)
|
9
9
|
guard (2.16.2)
|
@@ -25,6 +25,7 @@ GEM
|
|
25
25
|
rb-inotify (~> 0.9, >= 0.9.10)
|
26
26
|
lumberjack (1.2.4)
|
27
27
|
method_source (0.9.2)
|
28
|
+
multi_json (1.14.1)
|
28
29
|
nenv (0.3.0)
|
29
30
|
notiffany (0.1.3)
|
30
31
|
nenv (~> 0.1)
|
@@ -43,7 +44,7 @@ GEM
|
|
43
44
|
rspec-mocks (~> 3.9.0)
|
44
45
|
rspec-core (3.9.1)
|
45
46
|
rspec-support (~> 3.9.1)
|
46
|
-
rspec-expectations (3.9.
|
47
|
+
rspec-expectations (3.9.1)
|
47
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
49
|
rspec-support (~> 3.9.0)
|
49
50
|
rspec-mocks (3.9.1)
|
@@ -51,10 +52,11 @@ GEM
|
|
51
52
|
rspec-support (~> 3.9.0)
|
52
53
|
rspec-support (3.9.2)
|
53
54
|
shellany (0.0.1)
|
54
|
-
simplecov (0.
|
55
|
-
docile (~> 1.1)
|
56
|
-
|
57
|
-
|
55
|
+
simplecov (0.8.2)
|
56
|
+
docile (~> 1.1.0)
|
57
|
+
multi_json
|
58
|
+
simplecov-html (~> 0.8.0)
|
59
|
+
simplecov-html (0.8.0)
|
58
60
|
thor (1.0.1)
|
59
61
|
|
60
62
|
PLATFORMS
|
@@ -65,8 +67,7 @@ DEPENDENCIES
|
|
65
67
|
pry
|
66
68
|
pry-nav
|
67
69
|
rspec
|
68
|
-
simplecov
|
69
|
-
simplecov-html
|
70
|
+
simplecov (~> 0.8.2)
|
70
71
|
|
71
72
|
BUNDLED WITH
|
72
|
-
|
73
|
+
1.17.2
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'pry'
|
4
4
|
require 'yaml'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require 'rast/rast_spec'
|
6
|
+
require 'rast/rules/rule'
|
7
|
+
require 'rast/rules/rule_evaluator'
|
8
|
+
require 'rast/rules/rule_validator'
|
9
9
|
|
10
|
-
|
10
|
+
require 'rast/converters/float_converter'
|
11
11
|
|
12
12
|
# Generates the test parameters.
|
13
13
|
class ParameterGenerator
|
@@ -39,12 +39,12 @@ class ParameterGenerator
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def valid_case?(scenario, spec)
|
42
|
-
return true if spec.
|
42
|
+
return true if spec.exclude_clause.nil?
|
43
43
|
|
44
|
-
|
44
|
+
exclude_clause = spec.exclude_clause
|
45
45
|
rule_evaluator = RuleEvaluator.new(converters: spec.converters)
|
46
|
-
rule_evaluator.parse(
|
47
|
-
|
46
|
+
rule_evaluator.parse(expression: exclude_clause)
|
47
|
+
rule_evaluator.evaluate(scenario: scenario, rule_token_convert: spec.converters) == "false"
|
48
48
|
end
|
49
49
|
|
50
50
|
# add all fixtures to the list.
|
@@ -95,6 +95,8 @@ class ParameterGenerator
|
|
95
95
|
pair_config = spec_config['pair']
|
96
96
|
spec.init_pair(pair_config: pair_config) unless pair_config.nil?
|
97
97
|
|
98
|
+
spec.init_exclusion(spec_config['exclude']) unless spec_config['exclude'].nil?
|
99
|
+
|
98
100
|
converters = if spec_config['converters'].nil?
|
99
101
|
str_converter = StrConverter.new
|
100
102
|
spec_config['variables'].map { |_var| str_converter }
|
data/lib/rast/rast_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# CaseFixture.java, containing an actual and specific combination of variables.
|
4
4
|
class RastSpec
|
5
5
|
attr_reader :variables, :pair, :pair_reversed, :rule, :description,
|
6
|
-
:
|
6
|
+
:exclude_clause, :converters
|
7
7
|
|
8
8
|
attr_accessor :exclude
|
9
9
|
|
@@ -13,12 +13,14 @@ class RastSpec
|
|
13
13
|
@pair = {}
|
14
14
|
@pair_reversed = {}
|
15
15
|
@rule = rule
|
16
|
-
@
|
16
|
+
@exclude_clause = nil
|
17
17
|
end
|
18
18
|
|
19
19
|
def init_pair(pair_config: {})
|
20
20
|
@pair[pair_config.keys.first.to_s] = pair_config.values.first.to_s
|
21
|
-
|
21
|
+
|
22
|
+
array = [@pair.to_a.first.reverse]
|
23
|
+
@pair_reversed = { "#{array.first}".to_sym => array.last }
|
22
24
|
self
|
23
25
|
end
|
24
26
|
|
@@ -27,8 +29,8 @@ class RastSpec
|
|
27
29
|
self
|
28
30
|
end
|
29
31
|
|
30
|
-
def
|
31
|
-
@
|
32
|
+
def init_exclusion(exclude_clause)
|
33
|
+
@exclude_clause = exclude_clause
|
32
34
|
self
|
33
35
|
end
|
34
36
|
|
@@ -25,7 +25,7 @@ module LogicHelper
|
|
25
25
|
elsif TRUE == left && TRUE == right
|
26
26
|
TRUE
|
27
27
|
elsif TRUE == left
|
28
|
-
if right_subscript
|
28
|
+
if right_subscript < 0
|
29
29
|
scenario.include?(right).to_s
|
30
30
|
else
|
31
31
|
(scenario[right_subscript] == right).to_s
|
@@ -73,7 +73,7 @@ module LogicHelper
|
|
73
73
|
(scenario[right_subscript] == right).to_s
|
74
74
|
end
|
75
75
|
elsif FALSE == right
|
76
|
-
if left_subscript
|
76
|
+
if left_subscript < 0
|
77
77
|
scenario.include?(left).to_s
|
78
78
|
else
|
79
79
|
(scenario[left_subscript]).to_s == left
|
@@ -103,7 +103,7 @@ module LogicHelper
|
|
103
103
|
# * @param object left or right token.
|
104
104
|
# */
|
105
105
|
def pevaluate(scenario: [], subscript: -1, object: nil)
|
106
|
-
if subscript
|
106
|
+
if subscript < 0
|
107
107
|
scenario.include?(object)
|
108
108
|
else
|
109
109
|
scenario[subscript] == object
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require 'rast/rules/operator'
|
4
|
+
require 'rast/rules/logic_helper'
|
5
5
|
require 'rast/converters/int_converter'
|
6
6
|
require 'rast/converters/bool_converter'
|
7
7
|
require 'rast/converters/str_converter'
|
@@ -91,7 +91,7 @@ class RuleEvaluator
|
|
91
91
|
def next_value(rule_token_convert: {}, default_converter: nil)
|
92
92
|
subscript = -1
|
93
93
|
retval = []
|
94
|
-
value = @stack_answer.pop
|
94
|
+
value = @stack_answer.pop
|
95
95
|
if TRUE != value && FALSE != value
|
96
96
|
subscript = extract_subscript(token: value.to_s)
|
97
97
|
value_str = value.to_s.strip
|
@@ -182,7 +182,8 @@ class RuleEvaluator
|
|
182
182
|
|
183
183
|
raise 'Some operator is missing' if @stack_answer.size > 1
|
184
184
|
|
185
|
-
@stack_answer.pop
|
185
|
+
last = @stack_answer.pop
|
186
|
+
last[1..last.size]
|
186
187
|
end
|
187
188
|
|
188
189
|
# /**
|
data/lib/rast/spec_dsl.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rast/parameter_generator'
|
4
4
|
|
5
5
|
# Main DSL. This is the entry point of the test when running a spec.
|
6
6
|
class SpecDSL
|
@@ -22,6 +22,10 @@ class SpecDSL
|
|
22
22
|
@outcome = outcome.to_s
|
23
23
|
end
|
24
24
|
|
25
|
+
def respond_to_missing?(*several_variants)
|
26
|
+
super(several_variants)
|
27
|
+
end
|
28
|
+
|
25
29
|
def method_missing(method_name_symbol, *args, &block)
|
26
30
|
return super if method_name_symbol == :to_ary
|
27
31
|
|
@@ -42,7 +46,7 @@ class SpecDSL
|
|
42
46
|
def execute(&block)
|
43
47
|
@execute_block = block
|
44
48
|
|
45
|
-
@fixtures.sort_by! { |fixture| fixture[:expected_outcome] }
|
49
|
+
@fixtures.sort_by! { |fixture| fixture[:expected_outcome] + fixture[:scenario].to_s }
|
46
50
|
generate_rspecs
|
47
51
|
end
|
48
52
|
|
@@ -72,7 +76,10 @@ def generate_rspec(scope: nil, scenario: {}, expected: '')
|
|
72
76
|
|
73
77
|
it "[#{expected}]=[#{spec_params}]" do
|
74
78
|
block_params = scenario.values
|
75
|
-
|
79
|
+
|
80
|
+
if scope.rspec_methods.size > 0 || !scope.prepare_block.nil?
|
81
|
+
scope.prepare_block.call(*block_params)
|
82
|
+
end
|
76
83
|
|
77
84
|
while scope.rspec_methods.any?
|
78
85
|
first_meth = scope.rspec_methods.shift
|
data/lib/rast.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rspec'
|
4
|
-
|
5
|
-
|
4
|
+
require 'rast/parameter_generator'
|
5
|
+
require 'rast/spec_dsl'
|
6
6
|
|
7
7
|
# Main DSL. This is the entry point of the test when running a spec.
|
8
8
|
class Rast
|
data/rast.gemspec
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'lib/rast/version'
|
4
|
-
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = 'rast'
|
7
|
-
spec.version =
|
5
|
+
spec.version = '0.1.1.pre'
|
8
6
|
spec.authors = ['Royce Remulla']
|
9
7
|
spec.email = ['royce.com@gmail.com']
|
10
8
|
|
@@ -12,18 +10,17 @@ Gem::Specification.new do |spec|
|
|
12
10
|
spec.description = 'Extends RSpec functionality by using the catch-all-scenario testing (CAST) principle.'
|
13
11
|
spec.homepage = 'https://github.com/roycetech/rast'
|
14
12
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.0')
|
16
14
|
|
17
15
|
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
18
16
|
# spec.metadata['homepage_uri'] = spec.homepage
|
19
17
|
# spec.metadata['source_code_uri'] = "TODO: Put your gem's public repo URL here."
|
20
|
-
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/roycetech/rast/CHANGELOG.md'
|
21
19
|
|
22
|
-
|
23
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
spec.files = Dir.chdir(File.expand_path('.')) do
|
25
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
22
|
end
|
23
|
+
|
27
24
|
spec.bindir = 'exe'
|
28
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
26
|
spec.require_paths = %w[lib]
|
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.1.
|
4
|
+
version: 0.1.1.pre
|
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-
|
11
|
+
date: 2020-04-20 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,10 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
21
|
+
- .gitignore
|
22
|
+
- .rspec
|
23
|
+
- .rubocop.yml
|
24
|
+
- CHANGELOG.md
|
24
25
|
- Gemfile
|
25
26
|
- Gemfile.lock
|
26
27
|
- Guardfile
|
@@ -44,29 +45,29 @@ files:
|
|
44
45
|
- lib/rast/rules/rule_processor.rb
|
45
46
|
- lib/rast/rules/rule_validator.rb
|
46
47
|
- lib/rast/spec_dsl.rb
|
47
|
-
- lib/rast/version.rb
|
48
48
|
- lib/template_spec.yml
|
49
49
|
- rast.gemspec
|
50
50
|
homepage: https://github.com/roycetech/rast
|
51
51
|
licenses:
|
52
52
|
- MIT
|
53
|
-
metadata:
|
53
|
+
metadata:
|
54
|
+
changelog_uri: https://github.com/roycetech/rast/CHANGELOG.md
|
54
55
|
post_install_message:
|
55
56
|
rdoc_options: []
|
56
57
|
require_paths:
|
57
58
|
- lib
|
58
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
|
-
- -
|
61
|
+
- - ~>
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
63
|
+
version: '2.0'
|
63
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
|
-
- -
|
66
|
+
- - '>'
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: 1.3.1
|
68
69
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.0.8
|
70
71
|
signing_key:
|
71
72
|
specification_version: 4
|
72
73
|
summary: RSpec AST - All Scenario Testing
|
data/lib/rast/version.rb
DELETED