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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a7eb1b01e30dda0f5b204eef32ac2ec59c19384b37500f40587a1a522fce6db
4
- data.tar.gz: be19e4c8f4741658ef2aea98891b8bf040a250361fe48fee5219b02cc297b10f
3
+ metadata.gz: 958cf59b6aea2f5e323b849c83a86399cd9ad99e2433b899160a2422275a319e
4
+ data.tar.gz: bdb36f749b6bfcb87683f12d3db9e74c716bdbfbf41e21c845864bf1e17f7a7e
5
5
  SHA512:
6
- metadata.gz: 565a5d6628dd7f3904f97343da33539eaddf97c6fa020d2c14736ed84a146c3fe3d0aa7eb6fdfc73a94a3238be3bba40d892f07281d231918022b2c96fb95ce6
7
- data.tar.gz: 245f56b40a04d626c653e679b3634a5e1f3805a4f356c6f009759cb9e350e675b89e17e699e430fac5ffcb596e83c19190b929b4086b1da42254f2ffdbc7ea60
6
+ metadata.gz: 6f4b098047917136946c7bb88b111b5e6facf2a13ab70677bf0bce480bc2b4f0931f89f0be8ad2dc6db152abaaeffbdece5993d7ac5fba2ca85fde601df0c4c2
7
+ data.tar.gz: 7d5d125189afacf46a008a6b12c79ec68ffeb6e15c4324c1a6924a19be9061dac5760224225a564a8a1d9410b18a3da80591beeb30e5abc15995a5094326fab4
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2021 Cyril Kato
3
+ Copyright (c) 2020-2022 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Brutal 💎🔨
2
2
 
3
- [![RuboCop Status](https://github.com/fixrb/brutal/workflows/RuboCop/badge.svg)][workflow_rubocop]
4
- [![Build Status](https://api.travis-ci.org/fixrb/brutal.svg?branch=main)][travis]
5
- [![Gem Version](https://badge.fury.io/rb/brutal.svg)][gem]
6
- [![Inline docs](https://inch-ci.org/github/fixrb/brutal.svg?branch=main)][inchpages]
7
- [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
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.<br/>
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__ shape for you in no time the actual behavior of your code through as many combinations of contexts as needed.
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'll be able to focus on your core business: the code itself.
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
- __Brutal__ development process does not prevent from bugs.
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
- As a _picture of the behavior of the code_,
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
- However, this document becomes relevant when it shows that the code behaves as it is supposed to.
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
- $ bundle install
46
+ ```sh
47
+ bundle install
48
+ ```
47
49
 
48
50
  Or install it yourself as:
49
51
 
50
- $ gem install brutal
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://opensource.org/licenses/MIT).
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
@@ -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
- DEFAULT_HEAD = "# Brutal test suite"
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("actuals", DEFAULT_ACTUALS),
19
- contexts: params.fetch("contexts", DEFAULT_CONTEXTS),
20
- header: params.fetch("header", DEFAULT_HEAD),
21
- subject: params.fetch("subject", DEFAULT_SUBJECT)
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
 
@@ -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
- "# #{'-' * 78}\n" \
76
- "\n"
72
+ "# #{"-" * 78}\n" \
73
+ "\n"
77
74
  end
78
75
 
79
76
  def context_names
data/lib/brutal.rb CHANGED
@@ -14,6 +14,7 @@ module Brutal
14
14
  yaml = File::Read.new.call
15
15
  hash = Yaml.parse(yaml)
16
16
  conf = Configuration.load(hash)
17
+
17
18
  ruby = Scaffold.new(conf.header,
18
19
  conf.subject,
19
20
  *conf.actuals,
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.0
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: 2021-05-12 00:00:00.000000000 Z
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.4
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.