rast 0.1.2.pre → 0.3.0.pre

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: 61e7fa17b5ace2ff106da6596ebd01b2c2eb86108164e7218724bf8d694cb649
4
- data.tar.gz: df4432d78b4d353c7977969d96cfab2f7809db2c6e70b31c6b82ad95fc80298f
3
+ metadata.gz: 8391dc80e151d193090188d90cd08e7e596056275fad1d10fe24c47cc8a43cd9
4
+ data.tar.gz: abbc0bfc9e056de88bab998f3c5ebb36234650a884d650c2d96c00efd113ef9a
5
5
  SHA512:
6
- metadata.gz: 4b2b1229f6c792830818032f0bf4033ddee513618f19f02c29160222f831bbf9b3751d2d3bca49115b2b633eba6ea86afa1da20ed7507cb6a5bd2bce2513f1ba
7
- data.tar.gz: c13bcce9b0590bdd9cb53f9d44d76b5cf405c2eb3d542836dbf3c9fd96c639a58b2f80a7f5071ea7ea8fcdd064493cf953530bde1cd43aecbe15c1c1e52cafdf
6
+ metadata.gz: 37ab3933ed59e5d347faceeba789e59b6af71fcb7384a035db7b9a6d1c67371e507ad74c4f19ce5b04f77074ab5a887b2151da267b02e29a3e6519ee02ad1ec1
7
+ data.tar.gz: be8bfaf8cebaceb398e74d2902a29b3ac78c131445ac1850fc3b1c39dfbabd986c017e353fd3728b95df395493ef35ac77e02193acf4889435d43770b59eff4f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Change log
2
2
 
3
- 0.1.2.pre - Fixed exclusions
4
- 0.1.1.pre - Pre release version compatible with Ruby 2.0.0-p247
3
+
4
+ - 0.3.0.pre - Support factory methods in execute block
5
+ - 0.2.0.pre - Support module subjects
6
+ - 0.1.2.pre - Fixed exclusions
7
+ - 0.1.1.pre - Pre release version compatible with Ruby 2.0.0-p247
data/Gemfile CHANGED
@@ -5,6 +5,12 @@ source 'https://rubygems.org'
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  group :test do
8
+ gem 'factory_girl', '~> 4.7'
9
+
10
+ gem 'listen', '>= 3.0.8'
11
+ gem 'lumberjack', '~> 1.0', '>= 1.0.13'
12
+ gem 'rb-inotify', '~> 0.9.10'
13
+
8
14
  gem 'guard-rspec', require: false
9
15
  gem 'pry'
10
16
  gem 'pry-nav'
data/Gemfile.lock CHANGED
@@ -1,9 +1,17 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
+ activesupport (4.2.11.1)
5
+ i18n (~> 0.7)
6
+ minitest (~> 5.1)
7
+ thread_safe (~> 0.3, >= 0.3.4)
8
+ tzinfo (~> 1.1)
4
9
  coderay (1.1.2)
10
+ concurrent-ruby (1.1.6)
5
11
  diff-lcs (1.3)
6
12
  docile (1.1.5)
13
+ factory_girl (4.9.0)
14
+ activesupport (>= 3.0.0)
7
15
  ffi (1.12.2)
8
16
  formatador (0.2.5)
9
17
  guard (2.16.2)
@@ -20,11 +28,14 @@ GEM
20
28
  guard (~> 2.1)
21
29
  guard-compat (~> 1.1)
22
30
  rspec (>= 2.99.0, < 4.0)
23
- listen (3.2.1)
24
- rb-fsevent (~> 0.10, >= 0.10.3)
25
- rb-inotify (~> 0.9, >= 0.9.10)
26
- lumberjack (1.2.4)
31
+ i18n (0.9.5)
32
+ concurrent-ruby (~> 1.0)
33
+ listen (3.0.8)
34
+ rb-fsevent (~> 0.9, >= 0.9.4)
35
+ rb-inotify (~> 0.9, >= 0.9.7)
36
+ lumberjack (1.0.13)
27
37
  method_source (0.9.2)
38
+ minitest (5.12.0)
28
39
  multi_json (1.14.1)
29
40
  nenv (0.3.0)
30
41
  notiffany (0.1.3)
@@ -36,8 +47,8 @@ GEM
36
47
  pry-nav (0.3.0)
37
48
  pry (>= 0.9.10, < 0.13.0)
38
49
  rb-fsevent (0.10.3)
39
- rb-inotify (0.10.1)
40
- ffi (~> 1.0)
50
+ rb-inotify (0.9.10)
51
+ ffi (>= 0.5.0, < 2)
41
52
  rspec (3.9.0)
42
53
  rspec-core (~> 3.9.0)
43
54
  rspec-expectations (~> 3.9.0)
@@ -58,16 +69,23 @@ GEM
58
69
  simplecov-html (~> 0.8.0)
59
70
  simplecov-html (0.8.0)
60
71
  thor (1.0.1)
72
+ thread_safe (0.3.6)
73
+ tzinfo (1.2.7)
74
+ thread_safe (~> 0.1)
61
75
 
62
76
  PLATFORMS
63
77
  ruby
64
78
 
65
79
  DEPENDENCIES
80
+ factory_girl (~> 4.7)
66
81
  guard-rspec
82
+ listen (>= 3.0.8)
83
+ lumberjack (~> 1.0, >= 1.0.13)
67
84
  pry
68
85
  pry-nav
86
+ rb-inotify (~> 0.9.10)
69
87
  rspec
70
88
  simplecov (~> 0.8.2)
71
89
 
72
90
  BUNDLED WITH
73
- 1.17.2
91
+ 1.17.3
data/README.md CHANGED
@@ -3,23 +3,22 @@ RSpec All Scenario Testing
3
3
 
4
4
  ## Definition of terms
5
5
 
6
- spec - as defined in the yaml file, the individual elements under `specs`
7
-
8
- scenario - a specific combination of tokens from vars, it can uniquely identify a fixture.
9
-
10
- fixture - instance of a spec, containing a scenario, reference back to the spec, and the expected result for the given scenario.
11
-
12
- vars - raw list of variables to be combined into multiple fixtures.
13
-
14
- rule - set of outcome paired with rule clause.
15
- exemption/exclusions - rule defining variable combinations to be excluded from the test.
16
-
17
- outcome - the left portion of a rule e.g. `true: true&true`
18
-
19
- clause - the right portion of a rule
6
+ `spec` - as defined in the yaml file, the individual elements under `specs`
7
+ `scenario` - a specific combination of tokens from vars, it can uniquely identify a fixture.
8
+ `fixture` - instance of a spec, containing a scenario, reference back to the spec, and the expected result for the given scenario.
9
+ `variables` - raw list of variables to be combined into multiple fixtures.
10
+ `rule` - set of outcome paired with rule clause.
11
+ `exemption/exclusions` - rule defining variable combinations to be excluded from the test.
12
+ `outcome` - the left portion of a rule e.g. `true: true&true`
13
+ `clause` - the right portion of a rule
20
14
 
21
15
 
22
16
  ##
23
17
 
24
18
  When running the tests, the execution starts at the spec file, then invoking the
25
19
  DSL. The DSL will then invoke the parameter generator to generate the scenarios.
20
+
21
+ ## Adding new features
22
+
23
+ - Increment the .gemspec
24
+ - Modify the CHANGELOG.md
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Example module
4
+ module ArithmeticModule
5
+ def add(addend1, addend2)
6
+ addend1 + addend2
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Sample module
4
+ module FactoryExample
5
+ def phone_plan_name
6
+ return @phone.third_name if @phone.third_name
7
+ return @phone.second_name if @phone.second_name
8
+
9
+ @phone.first_name
10
+ end
11
+ end
data/examples/phone.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ class Phone
5
+ attr_accessor :first_name, :second_name, :third_name
6
+ end
@@ -20,7 +20,7 @@ class RastSpec
20
20
  @pair[pair_config.keys.first.to_s] = pair_config.values.first.to_s
21
21
 
22
22
  array = [@pair.to_a.first.reverse]
23
- @pair_reversed = { "#{array.first}".to_sym => array.last }
23
+ @pair_reversed = { array.first.to_s.to_sym => array.last }
24
24
  self
25
25
  end
26
26
 
@@ -28,7 +28,9 @@ class RastSpec
28
28
  @converters = {}
29
29
 
30
30
  @variables.keys.each_with_index do |key, index|
31
- @variables[key].each { |element| @converters[element.to_s] = converters[index] }
31
+ @variables[key].each do |element|
32
+ @converters[element.to_s] = converters[index]
33
+ end
32
34
  end
33
35
 
34
36
  self
@@ -3,6 +3,7 @@
3
3
  require 'rast/rules/operator'
4
4
  require 'rast/rules/logic_helper'
5
5
  require 'rast/converters/int_converter'
6
+ require 'rast/converters/float_converter'
6
7
  require 'rast/converters/bool_converter'
7
8
  require 'rast/converters/str_converter'
8
9
 
@@ -19,7 +20,7 @@ class RuleEvaluator
19
20
 
20
21
  # the "false" part of the "false[1]"
21
22
  RE_TOKEN_BODY = /^.+(?=\[)/.freeze
22
- RE_TOKENS = /([!|)(&])|([a-zA-Z\s0-9]+\[\d\])/.freeze
23
+ RE_TOKENS = /([!|)(&])|([a-zA-Z\s0-9-]+\[\d\])/.freeze
23
24
 
24
25
  def self.operator_from_symbol(symbol: nil)
25
26
  OPERATORS.find { |operator| operator.symbol == symbol }
@@ -27,6 +28,7 @@ class RuleEvaluator
27
28
 
28
29
  DEFAULT_CONVERT_HASH = {
29
30
  Integer => IntConverter.new,
31
+ Float => FloatConverter.new,
30
32
  TrueClass => BoolConverter.new,
31
33
  FalseClass => BoolConverter.new,
32
34
  String => StrConverter.new
@@ -32,7 +32,7 @@ class RuleValidator
32
32
  matched_outputs = []
33
33
  match_count = 0
34
34
 
35
- rule_result.map { |result| result == 'true' }.each_with_index do |result, i|
35
+ rule_result.map { |result| result.to_s == 'true' }.each_with_index do |result, i|
36
36
  next unless result
37
37
 
38
38
  match_count += 1
data/lib/rast/spec_dsl.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'factory_girl'
3
4
  require 'rast/parameter_generator'
4
5
 
5
6
  # Main DSL. This is the entry point of the test when running a spec.
6
7
  class SpecDSL
7
- attr_accessor :subject, :rspec_methods, :execute_block, :prepare_block,
8
- :transients, :outcomes, :fixtures
8
+ include FactoryGirl::Syntax::Methods
9
+
10
+ attr_accessor :subject, :rspec_methods, :execute_block,
11
+ :prepare_block, :transients, :outcomes, :fixtures
9
12
 
10
13
  def initialize(subject: nil, fixtures: [], &block)
11
14
  @subject = subject
@@ -46,7 +49,10 @@ class SpecDSL
46
49
  def execute(&block)
47
50
  @execute_block = block
48
51
 
49
- @fixtures.sort_by! { |fixture| fixture[:expected_outcome] + fixture[:scenario].to_s }
52
+ @fixtures.sort_by! do |fixture|
53
+ fixture[:expected_outcome] + fixture[:scenario].to_s
54
+ end
55
+
50
56
  generate_rspecs
51
57
  end
52
58
 
data/lib/rast.rb CHANGED
@@ -15,13 +15,14 @@ class Rast
15
15
  # Arguments:
16
16
  # language: (String)
17
17
 
18
-
19
-
20
18
  alias global_spec spec
21
19
 
22
- def initialize(rasted_class, &block)
23
- @rasted_class = rasted_class
24
- @subject = rasted_class.new
20
+ def initialize(rasted_subject, &block)
21
+ @subject = if rasted_subject.class == Module
22
+ Class.new { extend rasted_subject }
23
+ else
24
+ rasted_subject.new
25
+ end
25
26
 
26
27
  spec_path = caller[2][/spec.*?\.rb/]
27
28
  yaml_path = spec_path.gsub(/(\w+).rb/, 'rast/\\1.yml')
@@ -41,6 +42,6 @@ class Rast
41
42
  end
42
43
 
43
44
  # DSL Entry Point
44
- def rast(rasted_class, &block)
45
- Rast.new(rasted_class, &block)
45
+ def rast(rasted_subject, &block)
46
+ Rast.new(rasted_subject, &block)
46
47
  end
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.1.2.pre'
5
+ spec.version = '0.3.0.pre'
6
6
  spec.authors = ['Royce Remulla']
7
7
  spec.email = ['royce.com@gmail.com']
8
8
 
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
16
16
  # spec.metadata['homepage_uri'] = spec.homepage
17
17
  # spec.metadata['source_code_uri'] = "TODO: Put your gem's public repo URL here."
18
- spec.metadata['changelog_uri'] = 'https://github.com/roycetech/rast/CHANGELOG.md'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/roycetech/rast/blob/feature/ruby-2.0.0-support/CHANGELOG.md'
19
19
 
20
20
  spec.files = Dir.chdir(File.expand_path('.')) do
21
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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.2.pre
4
+ version: 0.3.0.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-21 00:00:00.000000000 Z
11
+ date: 2020-04-25 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.
@@ -24,9 +24,11 @@ files:
24
24
  - CHANGELOG.md
25
25
  - Gemfile
26
26
  - Gemfile.lock
27
- - Guardfile
28
27
  - README.md
28
+ - examples/arithmetic_module.rb
29
+ - examples/factory_example.rb
29
30
  - examples/logic_checker.rb
31
+ - examples/phone.rb
30
32
  - examples/prime_number.rb
31
33
  - examples/recruiter.rb
32
34
  - examples/worker.rb
@@ -51,7 +53,7 @@ homepage: https://github.com/roycetech/rast
51
53
  licenses:
52
54
  - MIT
53
55
  metadata:
54
- changelog_uri: https://github.com/roycetech/rast/CHANGELOG.md
56
+ changelog_uri: https://github.com/roycetech/rast/blob/feature/ruby-2.0.0-support/CHANGELOG.md
55
57
  post_install_message:
56
58
  rdoc_options: []
57
59
  require_paths:
data/Guardfile DELETED
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # A sample Guardfile
4
- # More info at https://github.com/guard/guard#readme
5
-
6
- ## Uncomment and set this to only include directories you want to watch
7
- # directories %w(app lib config test spec features) \
8
- # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
-
10
- ## Note: if you are using the `directories` clause above and you are not
11
- ## watching the project directory ('.'), then you will want to move
12
- ## the Guardfile to a watched dir and symlink it back, e.g.
13
- #
14
- # $ mkdir config
15
- # $ mv Guardfile config/
16
- # $ ln -s config/Guardfile .
17
- #
18
- # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
-
20
- # guard :rubocop do
21
- # watch(%r{.+\.rb$})
22
- # watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
23
- # end
24
-
25
- guard :rspec, cmd: 'bundle exec rspec -fd' do
26
- require 'guard/rspec/dsl'
27
-
28
- Guard::RSpec::Dsl.new(self)
29
-
30
- watch(%r{^spec/.+_spec\.rb$})
31
- # watch(%r{^spec\/.*?\/(.+_spec\.)yml$}) { |m| "#{m}.rb" }
32
- watch(%r{^lib/(.+)\.rb$}) { |_m| 'spec/examples/prime_number_spec.rb' }
33
- # watch(%r{^lib/(.+)\.rb$}) { |_m| 'spec/examples/logic_checker_spec.rb' }
34
- # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
35
- watch('spec/spec_helper.rb') { 'spec' }
36
- end