brutal 1.1.0 → 1.1.1

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: 31950aed12f6f2f8a292c6df194cbab35c832f649597df8a96f73a7852688da9
4
- data.tar.gz: 5300bdf71607debf6de06e4ddf37e8f7c7d4104822b18784cffed24451df8f30
3
+ metadata.gz: 98d43784db59dbf4d8263ec4730d302832e7e5edc46ebafc1a13d95935e9b697
4
+ data.tar.gz: e2d37b31d5b37387437e6ac80afb11b5b1a6d104cb677629ec3aafa9aae153af
5
5
  SHA512:
6
- metadata.gz: fd76ba0d91ce4a7df5c477906970e1affb5459d2dcffa03709d6078089e95b82a0a80b372d659e6306a870b5c6f73469c6bcf95e7c8367d09f833f53941fa0de
7
- data.tar.gz: 5cc889579792f8d836de4327eb83007c490e204016da975fdbe60792eea096d41c5906127a5210a5d2899cfc565024eede92d566ad69afe0b4f748fdbd46e8f1
6
+ metadata.gz: d3af04c68e89e7bdd965163066db2b99a4e3df78846ea6f33a0a89b9fe443e477376a6108a31c8b69d86d45f04459991d503f56c345b5089b7233a22b0d831bd
7
+ data.tar.gz: 55e326bf5cdcba338c63d7e57a8f75378f9869fe0f986867a86ece479850dd78745a2a568c3e0b89c8080f343e977b17d42b714e80dbbe3543b980204fd67c4d
data/README.md CHANGED
@@ -133,7 +133,7 @@ __Brutal__ follows [Semantic Versioning 2.0](https://semver.org/).
133
133
 
134
134
  ## License
135
135
 
136
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
136
+ The [gem](https://rubygems.org/gems/brutal) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
137
137
 
138
138
  ***
139
139
 
@@ -8,12 +8,12 @@
8
8
  yaml
9
9
  ].each { |file_name| require_relative(File.join('brutal', file_name)) }
10
10
 
11
- # The Brutal namespace
11
+ # The Brutal namespace.
12
12
  module Brutal
13
13
  def self.generate!
14
14
  yaml = File::Read.new.call
15
15
  hash = Yaml.parse(yaml)
16
- conf = Configuration.new(**hash)
16
+ conf = Configuration.load(hash)
17
17
  ruby = Scaffold.new(conf.header,
18
18
  conf.subject,
19
19
  *conf.actuals,
@@ -5,11 +5,37 @@ module Brutal
5
5
  #
6
6
  # @since 1.0.0
7
7
  class Configuration
8
- HEAD = '# Brutal test suite'
8
+ DEFAULT_ACTUALS = [].freeze
9
+ DEFAULT_CONTEXTS = {}.freeze
10
+ DEFAULT_HEAD = '# Brutal test suite'
11
+ DEFAULT_SUBJECT = ''
9
12
 
10
- attr_reader(:actuals, :contexts, :header, :subject)
13
+ # Load the configuration parameters.
14
+ #
15
+ # @param params [Hash] Receive the 4 top-level section parameters.
16
+ def self.load(params)
17
+ new(
18
+ actuals: params.fetch('actuals', DEFAULT_ACTUALS),
19
+ contexts: params.fetch('contexts', DEFAULT_CONTEXTS),
20
+ header: params.fetch('header', DEFAULT_HEAD),
21
+ subject: params.fetch('subject', DEFAULT_SUBJECT)
22
+ )
23
+ end
24
+
25
+ # Specifies templates to challenge evaluated subjects & get results.
26
+ attr_reader :actuals
27
+
28
+ # Specifies a list of variables to populate the subject's template.
29
+ attr_reader :contexts
30
+
31
+ # Specifies the code to execute before generating the test suite.
32
+ attr_reader :header
33
+
34
+ # Specifies the template of the code to be declined across contexts.
35
+ attr_reader :subject
11
36
 
12
- def initialize(actuals: [], contexts: {}, header: HEAD, subject: '')
37
+ # Initialize a new configuration.
38
+ def initialize(actuals:, contexts:, header:, subject:)
13
39
  raise ::TypeError, actuals.inspect unless actuals.is_a?(::Array)
14
40
  raise ::TypeError, contexts.inspect unless contexts.is_a?(::Hash)
15
41
  raise ::TypeError, header.inspect unless header.is_a?(::String)
@@ -5,9 +5,19 @@ module Brutal
5
5
  #
6
6
  # @since 1.0.0
7
7
  class Scaffold
8
- attr_reader(:header, :subject, :actuals, :contexts)
8
+ # Specifies templates to challenge evaluated subjects & get results.
9
+ attr_reader :actuals
9
10
 
10
- # Initialize a new scaffold generator
11
+ # Specifies a list of variables to populate the subject's template.
12
+ attr_reader :contexts
13
+
14
+ # Specifies the code to execute before generating the test suite.
15
+ attr_reader :header
16
+
17
+ # Specifies the template of the code to be declined across contexts.
18
+ attr_reader :subject
19
+
20
+ # Initialize a new scaffold generator.
11
21
  def initialize(header, subject, *actuals, **contexts)
12
22
  warn('Empty subject!') if subject.empty?
13
23
  warn('Empty actual values!') if actuals.empty?
@@ -28,13 +38,13 @@ module Brutal
28
38
  object.strip
29
39
  end
30
40
 
31
- # Return a string representation
41
+ # Return a string representation.
32
42
  #
33
43
  # @return [String]
34
44
  #
35
45
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
36
46
  def to_s
37
- header.chomp + "\n" + blank_line + combinations_values.map do |values|
47
+ "#{header.chomp}\n#{blank_line}" + combinations_values.map do |values|
38
48
  attributes = context_names.each_with_index.inject({}) do |h, (name, i)|
39
49
  h.merge(name.to_sym => inspect(values.fetch(i)))
40
50
  end
@@ -75,7 +85,7 @@ module Brutal
75
85
  end
76
86
 
77
87
  def combinations_values
78
- Array(contexts_values[0]).product(*Array(contexts_values[1..-1]))
88
+ Array(contexts_values[0]).product(*Array(contexts_values[1..]))
79
89
  end
80
90
  end
81
91
  end
@@ -8,7 +8,7 @@ module Brutal
8
8
  # @since 1.1.0
9
9
  module Yaml
10
10
  def self.parse(yaml)
11
- ::YAML.safe_load(yaml, symbolize_names: true)
11
+ ::YAML.safe_load(yaml, symbolize_names: false)
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brutal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-14 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.6.0
125
+ version: 2.7.0
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.0.1
132
+ rubygems_version: 3.1.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: A code-first approach to automate the writing of unit tests.