brutal 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +26 -24
- data/lib/brutal/configuration.rb +10 -5
- data/lib/brutal/scaffold.rb +3 -6
- data/lib/brutal.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 958cf59b6aea2f5e323b849c83a86399cd9ad99e2433b899160a2422275a319e
|
4
|
+
data.tar.gz: bdb36f749b6bfcb87683f12d3db9e74c716bdbfbf41e21c845864bf1e17f7a7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f4b098047917136946c7bb88b111b5e6facf2a13ab70677bf0bce480bc2b4f0931f89f0be8ad2dc6db152abaaeffbdece5993d7ac5fba2ca85fde601df0c4c2
|
7
|
+
data.tar.gz: 7d5d125189afacf46a008a6b12c79ec68ffeb6e15c4324c1a6924a19be9061dac5760224225a564a8a1d9410b18a3da80591beeb30e5abc15995a5094326fab4
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Brutal 💎🔨
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
3
|
+
[![Version](https://img.shields.io/github/v/tag/fixrb/brutal?label=Version&logo=github)](https://github.com/fixrb/brutal/releases)
|
4
|
+
[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/brutal/main)
|
5
|
+
[![CI](https://github.com/fixrb/brutal/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/brutal/actions?query=workflow%3Aci+branch%3Amain)
|
6
|
+
[![RuboCop](https://github.com/fixrb/brutal/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/brutal/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
|
+
[![License](https://img.shields.io/github/license/fixrb/brutal?label=License&logo=github)](https://github.com/fixrb/brutal/raw/main/LICENSE.md)
|
8
8
|
|
9
9
|
> A _code-first_ approach to automate the writing of unit tests.
|
10
10
|
|
@@ -12,26 +12,26 @@
|
|
12
12
|
|
13
13
|
[![I Hate Tests](https://github.com/fixrb/brutal/raw/main/img/rubyhack-2019-ruby3-what-s-missing-by-yukihiro-matsumoto.jpg)](https://www.youtube.com/embed/cmOt9HhszCI?start=1732&end=1736 "I don't like tests. It's not DRY.")
|
14
14
|
|
15
|
-
> I don't like tests. It's not DRY
|
15
|
+
> I don't like tests. It's not DRY.
|
16
16
|
> -- [Matz](https://github.com/matz)
|
17
17
|
|
18
18
|
## Overview
|
19
19
|
|
20
|
-
Let __Brutal__
|
20
|
+
Let __Brutal__ craft for you in no time a (potentially huge) framework-less vanilla Ruby file describing the actual behavior of your code across as many context combinations as necessary.
|
21
21
|
|
22
|
-
By delegating to __Brutal__ the repetitive (and redundant) task of writing tests, you
|
22
|
+
By delegating to __Brutal__ the repetitive (and redundant) task of writing tests, you will be able to focus on your core business: the code itself.
|
23
|
+
|
24
|
+
![Brutal-Driven Development](https://github.com/fixrb/brutal/raw/main/img/brutal-driven-development.jpg)
|
23
25
|
|
24
26
|
## Warning
|
25
27
|
|
26
|
-
|
28
|
+
The _Brutal-Driven Development_ process does not prevent bugs from appearing in the code.
|
29
|
+
|
30
|
+
A generated test suite acts as a _picture of the code's behavior_. Therefore, if the code is wrong, the picture of the code's behavior will also be wrong.
|
27
31
|
|
28
|
-
|
29
|
-
a generated test suite is wrong as long as the code is wrong,
|
30
|
-
regardless of whether all true expectations.
|
32
|
+
The mere fact that all expectations are true does not mean that the code behaves as it should.
|
31
33
|
|
32
|
-
|
33
|
-
It is therefore important to read it well.
|
34
|
-
This is the price for _Brutal-Driven Development_.
|
34
|
+
It is therefore the responsibility of the developer to analyze the generated behavioral pictures to ensure that the code reacts as it is supposed to according to the contexts in which it is evaluated.
|
35
35
|
|
36
36
|
## Installation
|
37
37
|
|
@@ -43,11 +43,15 @@ gem "brutal"
|
|
43
43
|
|
44
44
|
And then execute:
|
45
45
|
|
46
|
-
|
46
|
+
```sh
|
47
|
+
bundle install
|
48
|
+
```
|
47
49
|
|
48
50
|
Or install it yourself as:
|
49
51
|
|
50
|
-
|
52
|
+
```sh
|
53
|
+
gem install brutal
|
54
|
+
```
|
51
55
|
|
52
56
|
## Quick Start
|
53
57
|
|
@@ -123,6 +127,10 @@ Rake::TestTask.new do |t|
|
|
123
127
|
end
|
124
128
|
```
|
125
129
|
|
130
|
+
## Test suite
|
131
|
+
|
132
|
+
__Brutal__'s test set is brutally self-generated here: [./test.rb](https://github.com/fixrb/brutal/blob/main/test.rb)
|
133
|
+
|
126
134
|
## Contact
|
127
135
|
|
128
136
|
* Source code: https://github.com/fixrb/brutal
|
@@ -133,7 +141,7 @@ __Brutal__ follows [Semantic Versioning 2.0](https://semver.org/).
|
|
133
141
|
|
134
142
|
## License
|
135
143
|
|
136
|
-
The [gem](https://rubygems.org/gems/brutal) is available as open source under the terms of the [MIT License](https://
|
144
|
+
The [gem](https://rubygems.org/gems/brutal) is available as open source under the terms of the [MIT License](https://github.com/fixrb/brutal/raw/main/LICENSE.md).
|
137
145
|
|
138
146
|
***
|
139
147
|
|
@@ -143,9 +151,3 @@ The [gem](https://rubygems.org/gems/brutal) is available as open source under th
|
|
143
151
|
src="https://github.com/fixrb/brutal/raw/main/img/sashite.png"
|
144
152
|
alt="Sashite" /></a>
|
145
153
|
</p>
|
146
|
-
|
147
|
-
[workflow_rubocop]: https://github.com/fixrb/brutal/actions?query=workflow%3ARuboCop
|
148
|
-
[gem]: https://rubygems.org/gems/brutal
|
149
|
-
[travis]: https://travis-ci.org/fixrb/brutal
|
150
|
-
[inchpages]: https://inch-ci.org/github/fixrb/brutal
|
151
|
-
[rubydoc]: https://rubydoc.info/gems/brutal/frames
|
data/lib/brutal/configuration.rb
CHANGED
@@ -5,9 +5,14 @@ module Brutal
|
|
5
5
|
#
|
6
6
|
# @since 1.0.0
|
7
7
|
class Configuration
|
8
|
+
ACTUALS_KEY = "actuals"
|
9
|
+
CONTEXTS_KEY = "contexts"
|
10
|
+
HEADER_KEY = "header"
|
11
|
+
SUBJECT_KEY = "subject"
|
12
|
+
|
8
13
|
DEFAULT_ACTUALS = [].freeze
|
9
14
|
DEFAULT_CONTEXTS = {}.freeze
|
10
|
-
|
15
|
+
DEFAULT_HEADER = "# Brutal test suite"
|
11
16
|
DEFAULT_SUBJECT = ""
|
12
17
|
|
13
18
|
# Load the configuration parameters.
|
@@ -15,10 +20,10 @@ module Brutal
|
|
15
20
|
# @param params [Hash] Receive the 4 top-level section parameters.
|
16
21
|
def self.load(params)
|
17
22
|
new(
|
18
|
-
actuals: params.fetch(
|
19
|
-
contexts: params.fetch(
|
20
|
-
header: params.fetch(
|
21
|
-
subject: params.fetch(
|
23
|
+
actuals: params.fetch(ACTUALS_KEY, DEFAULT_ACTUALS),
|
24
|
+
contexts: params.fetch(CONTEXTS_KEY, DEFAULT_CONTEXTS),
|
25
|
+
header: params.fetch(HEADER_KEY, DEFAULT_HEADER),
|
26
|
+
subject: params.fetch(SUBJECT_KEY, DEFAULT_SUBJECT)
|
22
27
|
)
|
23
28
|
end
|
24
29
|
|
data/lib/brutal/scaffold.rb
CHANGED
@@ -41,8 +41,6 @@ module Brutal
|
|
41
41
|
# Return a string representation.
|
42
42
|
#
|
43
43
|
# @return [String]
|
44
|
-
#
|
45
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
46
44
|
def to_s
|
47
45
|
"#{header.chomp}\n#{blank_line}" + combinations_values.map do |values|
|
48
46
|
attributes = context_names.each_with_index.inject({}) do |h, (name, i)|
|
@@ -53,7 +51,7 @@ module Brutal
|
|
53
51
|
|
54
52
|
string = <<~CODE
|
55
53
|
actual = begin
|
56
|
-
#{actual_str.gsub(/^/,
|
54
|
+
#{actual_str.gsub(/^/, " ")}
|
57
55
|
end
|
58
56
|
|
59
57
|
CODE
|
@@ -68,12 +66,11 @@ module Brutal
|
|
68
66
|
string
|
69
67
|
end.join(blank_line)
|
70
68
|
end
|
71
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
72
69
|
|
73
70
|
def blank_line
|
74
71
|
"\n" \
|
75
|
-
|
76
|
-
|
72
|
+
"# #{"-" * 78}\n" \
|
73
|
+
"\n"
|
77
74
|
end
|
78
75
|
|
79
76
|
def context_names
|
data/lib/brutal.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,7 +141,8 @@ files:
|
|
141
141
|
homepage: https://github.com/fixrb/brutal
|
142
142
|
licenses:
|
143
143
|
- MIT
|
144
|
-
metadata:
|
144
|
+
metadata:
|
145
|
+
rubygems_mfa_required: 'true'
|
145
146
|
post_install_message:
|
146
147
|
rdoc_options: []
|
147
148
|
require_paths:
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: '0'
|
159
160
|
requirements: []
|
160
|
-
rubygems_version: 3.1.
|
161
|
+
rubygems_version: 3.1.6
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: A code-first approach to automate the writing of unit tests.
|