brutal 0.4.0 → 0.4.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: 4b21dc72c3687aa3893272f404e01d0329a528a61caa2b6f5ec251b5de66a3a4
4
- data.tar.gz: 9aeb0ad4c455bb747700dc3af6bdf8957376e100af6e7b11bc6b377218e12426
3
+ metadata.gz: 491dc26f34135ff61ceb54bc64b4dc5793e8b2610d545b3025b8c7aaf53b3064
4
+ data.tar.gz: e7c379c45ce23f0886041ec8a4b6ab4c493a91e450230b64968e45a92214a62e
5
5
  SHA512:
6
- metadata.gz: 7a818e0951d2993387caf80e699a989ffecca901f43ebf00b430b1de2ce330eb8da486c75800fd936a32b6f9b3286703d5ce4e85995b1a652f945ee9261162d3
7
- data.tar.gz: afeedf7b04fc5be914e400a2b1a2149b0f82fb45f069654f2cc0bcf72e64cc84fc1c906b52c780d5199c2897059e1fc8e6125c6667e32c8a26fd656ae645a0c8
6
+ metadata.gz: 8791614f90a92630a28aa3fb8b6d2a9d1921404b1cc614302bfeb8a87970186c33b935d81db81b7c1d8751475a59d5f32c17ea80627d32755daece880b93ace4
7
+ data.tar.gz: 19cf4fcbe94766983442f0f47b2651b5b675d5ade1c9b306e4213421d21253035545a23f8e6c988a8967db182b4de59a4158a545278684b4104039729963574c
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Cyril Kato
3
+ Copyright (c) 2020 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,5 +1,6 @@
1
1
  # Brutal 💎🔨
2
2
 
3
+ [![RuboCop Status](https://github.com/fixrb/brutal/workflows/RuboCop/badge.svg)][workflow_rubocop]
3
4
  [![Build Status](https://api.travis-ci.org/fixrb/brutal.svg?branch=master)][travis]
4
5
  [![Gem Version](https://badge.fury.io/rb/brutal.svg)][gem]
5
6
  [![Inline docs](https://inch-ci.org/github/fixrb/brutal.svg?branch=master)][inchpages]
@@ -7,7 +8,7 @@
7
8
 
8
9
  > A _code-first_ approach to automate the writing of unit tests.
9
10
 
10
- ## Intro
11
+ ## Why
11
12
 
12
13
  [![I Hate Tests](https://github.com/fixrb/brutal/raw/master/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.")
13
14
 
@@ -16,62 +17,20 @@
16
17
 
17
18
  ## Purpose
18
19
 
19
- Take a break and let __Brutal__ shape for you the actual behavior of your code against as many combinations of challenges as needed.
20
+ Let __Brutal__ shape for you the actual behavior of your code against as many combinations of challenges as needed.
20
21
 
21
22
  Without giving the power to test everything, it makes it easy to generate in no time a set of tests for all relevant contexts.
22
23
 
23
- By delegating to __Brutal__ the repetitive and redundant task of writing tests, you'll be able to focus on your core business: writing code.
24
+ By delegating to __Brutal__ this repetitive (and redundant) job of writing tests, you'll be able to focus on your core business: writing code.
24
25
 
25
26
  ## Warning
26
27
 
27
28
  __Brutal__ does not prevent from bugs.
28
- As a picture of the behavior of the code, its generated tests would be wrong if the code is wrong.
29
+ As a picture of the behavior of the code, generated tests would be wrong if the code is wrong.
29
30
 
30
- This is why it is important to carefully read the generated test suite, to ensure that it describes the behavior of the code as it is supposed to behave.
31
+ This is why it is important to carefully read a generated test suite, to ensure that it describes the behavior of the code as it is expected to behave.
31
32
 
32
- However, when the `brutal` command is executed successfully,
33
- we can consider that both __Brutal__'s configuration file (`.brutal.yml`) and evaluated code as syntactically correct.
34
-
35
- In the context of a versioned project, to avoid regressions,
36
- the integrity of the behavior of the code can easily be checked by re-generating a picture to be compared with the previous one.
37
- Here is an example with [The Greeter class](https://github.com/fixrb/brutal/raw/master/examples/the_greeter_class/) code:
38
-
39
- ```sh
40
- git diff
41
- ```
42
-
43
- The code:
44
-
45
- ```diff
46
- # The Greeter class
47
- class Greeter
48
- def initialize(name)
49
- - @name = name
50
- + @name = name.capitalize
51
- end
52
-
53
- def salute
54
- "Hello #{@name}!"
55
- end
56
- end
57
- ```
58
-
59
- The generated test of the code:
60
-
61
- ```diff
62
- require './greeter'
63
-
64
- # ------------------------------------------------------------------------------
65
-
66
- front_object = Greeter
67
-
68
- # ------------------------------------------------------------------------------
69
-
70
- actual = front_object.new('world')
71
-
72
- - raise unless actual.salute == "Hello world!"
73
- + raise unless actual.salute == "Hello World!"
74
- ```
33
+ This is the cost to enter the _Brutal-Driven Development_ with confidence.
75
34
 
76
35
  ## Installation
77
36
 
@@ -104,11 +63,38 @@ This YAML file can contains the following keys:
104
63
  * `variables` (required): A hash to generate the subject of each context.
105
64
  * `actual_values` (required): A list of tests to challenge the subject.
106
65
 
66
+ ### Behavioral integrity
67
+
68
+ In versioned projects,
69
+ the integrity of the behavior of the code could easily be compared by executing `brutal` after changes.
70
+
71
+ Assuming a project is versioned with git,
72
+ if something goes wrong, the `git diff test.rb` command should instantly show changes between the behavior of the previous code and the behavior of the new one.
73
+
74
+ Example of regression from [The Greeter class](https://github.com/fixrb/brutal/raw/master/examples/the_greeter_class/):
75
+
76
+ ```diff
77
+ require './greeter'
78
+
79
+ # ------------------------------------------------------------------------------
80
+
81
+ front_object = Greeter
82
+
83
+ # ------------------------------------------------------------------------------
84
+
85
+ actual = front_object.new('world')
86
+
87
+ - raise unless actual.salute == "Hello World!"
88
+ + raise unless actual.salute == "Hello !"
89
+ ```
90
+
107
91
  ### Optional parameters
108
92
 
109
93
  It would also be possible to ask for an RSpec template by passing "`rspec`" argument:
110
94
 
111
- > brutal rspec
95
+ ```sh
96
+ brutal rspec
97
+ ```
112
98
 
113
99
  ## Example
114
100
 
@@ -140,12 +126,14 @@ front_object = "Hello "
140
126
  # ------------------------------------------------------------------------------
141
127
 
142
128
  actual = front_object + 'Alice'
129
+
143
130
  raise unless actual.to_s == "Hello Alice"
144
131
  raise unless actual.length == 11
145
132
 
146
133
  # ------------------------------------------------------------------------------
147
134
 
148
135
  actual = front_object + 'Bob'
136
+
149
137
  raise unless actual.to_s == "Hello Bob"
150
138
  raise unless actual.length == 9
151
139
  ```
@@ -176,7 +164,7 @@ More examples are available [here](https://github.com/fixrb/brutal/raw/master/ex
176
164
 
177
165
  ## Rake integration example
178
166
 
179
- The generated brutal test suite `test.rb` file can be declared as follows:
167
+ A generated `test.rb` file could be matched as follows:
180
168
 
181
169
  ```ruby
182
170
  Rake::TestTask.new do |t|
@@ -186,14 +174,7 @@ end
186
174
 
187
175
  ## Contact
188
176
 
189
- * Home page: https://github.com/fixrb/brutal
190
- * Bugs/issues: https://github.com/fixrb/brutal/issues
191
-
192
- ## Rubies
193
-
194
- * [MRI](https://www.ruby-lang.org/)
195
- * [Rubinius](https://rubinius.com/)
196
- * [JRuby](https://www.jruby.org/)
177
+ * Source code: https://github.com/fixrb/brutal
197
178
 
198
179
  ## Versioning
199
180
 
@@ -212,6 +193,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
212
193
  alt="Sashite" /></a>
213
194
  </p>
214
195
 
196
+ [workflow_rubocop]: https://github.com/fixrb/brutal/actions?query=workflow%3ARuboCop
215
197
  [gem]: https://rubygems.org/gems/brutal
216
198
  [travis]: https://travis-ci.org/fixrb/brutal
217
199
  [inchpages]: https://inch-ci.org/github/fixrb/brutal
@@ -30,7 +30,13 @@ module Brutal
30
30
 
31
31
  actual_str = format(inspect(subject), **attributes)
32
32
 
33
- string = "actual = #{actual_str}\n\n"
33
+ string = <<~CODE
34
+ actual = begin
35
+ #{actual_str.gsub(/^/, ' ')}
36
+ end
37
+
38
+ CODE
39
+
34
40
  actual = eval(actual_str) # rubocop:disable Security/Eval, Lint/UselessAssignment
35
41
 
36
42
  actual_values.each do |actual_value|
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: 0.4.0
4
+ version: 0.4.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: 2019-12-28 00:00:00.000000000 Z
11
+ date: 2020-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.79'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.79'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-performance
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.17'
83
+ - !ruby/object:Gem::Dependency
84
+ name: spectus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: yard
85
99
  requirement: !ruby/object:Gem::Requirement