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 CHANGED
@@ -1,7 +1,4 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: eb63e35c4439e5fc90b4e25ce9981739f624a114d6f8848eb07576eac93e9222
4
- data.tar.gz: 12f0b43bd2385dada9e6272e8895054911c3bee8fbe2ff267914ceae996f5a82
5
2
  SHA512:
6
- metadata.gz: 5c39d99e9dde201939565dc47372a0cff3be2e83a77ca2162275982ac15b7e73fc8fa83270761ed7b615093e078ed0d6a4324f30883de1258bb38a14082f8fad
7
- data.tar.gz: 103f18839c943b5c30af075fe567386d553be83a7f9f4598e5a77c3917df19362a60fbcaca65bf30873dcbc52b64470cad6318584a037d560732af0eb24921c0
3
+ metadata.gz: 27a95910bf913315b1188d751aaabefe976ebcc78ae8f827fdc71d5ca8d0ff162e3a0fa2af20abdccaf1ba8d5ba62d6cc2f9b470c3b38c05198c6e8a0109b6f4
4
+ data.tar.gz: 9704f5073764d040472332937b435d5156b6457309d5ab08cbe0b6eb1c2d79f2b523fd00e391fc5eec7ae95ce0a4428b1f1805b4ed43a1e9ee8275d732eb9627
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # Change log
2
+
3
+ 0.1.1.pre - Pre release version compatible with Ruby 2.0.0-p247
data/Gemfile CHANGED
@@ -9,6 +9,5 @@ group :test do
9
9
  gem 'pry'
10
10
  gem 'pry-nav'
11
11
  gem 'rspec'
12
- gem 'simplecov'
13
- gem 'simplecov-html'
12
+ gem 'simplecov', '~> 0.8.2'
14
13
  end
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.3.2)
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.0)
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.18.5)
55
- docile (~> 1.1)
56
- simplecov-html (~> 0.11)
57
- simplecov-html (0.12.2)
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
- 2.1.4
73
+ 1.17.2
@@ -2,12 +2,12 @@
2
2
 
3
3
  require 'pry'
4
4
  require 'yaml'
5
- require_relative 'rast_spec'
6
- require_relative 'rules/rule'
7
- require_relative 'rules/rule_evaluator'
8
- require_relative 'rules/rule_validator'
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
- require_relative 'converters/float_converter'
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.exempt_rule.nil?
42
+ return true if spec.exclude_clause.nil?
43
43
 
44
- exempt_rule = fixture.exempt_rule
44
+ exclude_clause = spec.exclude_clause
45
45
  rule_evaluator = RuleEvaluator.new(converters: spec.converters)
46
- rule_evaluator.parse(exempt_rule)
47
- !ruleEvaluator.evaluate(scenario, spec.converters)
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 }
@@ -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
- :exempt_rule, :converters
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
- @exempt_rule = nil
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
- @pair_reversed = [@pair.to_a.first.reverse].to_h
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 init_exempt_rule(exempt_rule)
31
- @exempt_rule = exempt_rule
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.negative?
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.negative?
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.negative?
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
- require_relative 'operator'
4
- require_relative 'logic_helper'
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&.strip
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[1..]
185
+ last = @stack_answer.pop
186
+ last[1..last.size]
186
187
  end
187
188
 
188
189
  # /**
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'rule_evaluator'
3
+ require 'rast/rules/rule_evaluator'
4
4
 
5
5
  # undoc
6
6
  class RuleProcessor
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rast/assert'
4
- require_relative 'rule_processor'
4
+ require 'rast/rules/rule_processor'
5
5
 
6
6
  # Validates rules
7
7
  class RuleValidator
data/lib/rast/spec_dsl.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'parameter_generator'
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
- scope.prepare_block&.call(*block_params) unless scope.rspec_methods.any?
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
- require_relative 'rast/parameter_generator'
5
- require_relative 'rast/spec_dsl'
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 = Rast::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('>= 2.3.0')
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
- # spec.metadata['changelog_uri'] = "TODO: Put your gem's CHANGELOG.md URL here."
18
+ spec.metadata['changelog_uri'] = 'https://github.com/roycetech/rast/CHANGELOG.md'
21
19
 
22
- # Specify which files should be added to the gem when it is released.
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.0.pre
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-18 00:00:00.000000000 Z
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
- - ".gitignore"
22
- - ".rspec"
23
- - ".rubocop.yml"
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.3.0
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.1.2
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
@@ -1,3 +0,0 @@
1
- module Rast
2
- VERSION = '0.1.0.pre'.freeze
3
- end