regtest 0.5.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +3 -0
- data/Gemfile +3 -0
- data/LICENSE +3 -0
- data/README.md +127 -68
- data/Rakefile +17 -3
- data/lib/regtest.rb +3 -1
- data/lib/regtest/task.rb +7 -0
- data/regtest.gemspec +38 -0
- data/regtest/combinations.rb +3 -0
- data/regtest/example.rb +3 -0
- metadata +20 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: accc98eaba516d684361d2dbe6a3d3bb13699ba8
|
4
|
+
data.tar.gz: 55c62a159fcbd0f218aaeb2ff69a70b4914a1f9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15f9eca32bcfb978ff004972b19e51dbab4542a2f0fe098aebdb8c9600d76b836b0bead6e0c922d0c2a03773775113b9bd32aa867a1da548cf725295d622a329
|
7
|
+
data.tar.gz: d39493f32b6cdaa8dc1bce1874f48cba1e75ce18b3b925ac2682c291d091c2035981c23e19bfdf560749c64fb6f07eeaa769ff5acdcc7b0d38dd248d54ebd125
|
data/Changelog
CHANGED
data/Gemfile
ADDED
data/LICENSE
ADDED
data/README.md
CHANGED
@@ -2,119 +2,178 @@
|
|
2
2
|
|
3
3
|
## Description
|
4
4
|
|
5
|
-
This library support a very simple way to do regression testing in Ruby
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
This library support a very simple way to do regression testing in Ruby
|
6
|
+
projects. You write Ruby scripts with samples. Run these and get the sample
|
7
|
+
results as YAML output besides your scripts. Check both the scripts and the YAML
|
8
|
+
files with the results in you Source Code Control System. When you run the
|
9
|
+
scrips on a later (or even previous) version of your code a simple diff show you
|
10
|
+
if and how the changes in your code impact the results of your samples.
|
11
|
+
|
12
|
+
This is not a replacement for unit testing but a complement: You can produce a
|
13
|
+
lot of samples with a small amount of Ruby code (e.g. a large number of
|
14
|
+
combinations of data).
|
15
|
+
|
11
16
|
|
12
17
|
## Installation
|
13
18
|
|
14
|
-
Installing the gem with
|
19
|
+
Installing the gem on the command line with
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gem install regtest
|
23
|
+
```
|
15
24
|
|
16
|
-
|
25
|
+
or add
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'regtest'
|
29
|
+
```
|
30
|
+
to your Gemfile or put a copy of `regtest.rb` in your project.
|
17
31
|
|
18
|
-
or put a copy of regtest.rb in your project.
|
19
32
|
|
20
33
|
## Using
|
21
34
|
|
22
35
|
The idea behind regtest is the following workflow:
|
23
36
|
1. Writing samples
|
24
37
|
2. Running samples
|
25
|
-
3. Checking results (differences between the actual results and the
|
26
|
-
|
38
|
+
3. Checking results (differences between the actual results and the results of
|
39
|
+
a previous run of your samples using the diff functionality of your Source
|
40
|
+
Code Control System)
|
41
|
+
|
27
42
|
|
28
43
|
### Writing Samples
|
29
44
|
|
30
|
-
A samples file is a simple Ruby script with one ore more samples,
|
31
|
-
|
45
|
+
A samples file is a simple Ruby script with one ore more samples, for example
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'regtest'
|
49
|
+
|
50
|
+
Regtest.sample 'String result' do
|
51
|
+
# Doing something to get the result of the sample
|
52
|
+
# end make sure it is the result of the block
|
53
|
+
'some text'
|
54
|
+
end
|
55
|
+
|
56
|
+
Regtest.sample 'Division by zero' do
|
57
|
+
# If an exception occurs while execution of the
|
58
|
+
# block it is catched and used as value for the
|
59
|
+
# sample
|
60
|
+
2 / 0
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
The name of the sample (parameter of the `Regtest.sample` method) and the
|
65
|
+
results of the samples (return value of the block) are stored in YAML format. So
|
66
|
+
it should be a YAML friendly value as `String`, `Number`, `Boolean value`,
|
67
|
+
`Symbol`. Results could also be an `Array` or `Hash` with such values.
|
68
|
+
|
69
|
+
|
70
|
+
#### Helpers
|
32
71
|
|
33
|
-
|
72
|
+
There is a method `Regtest.combinations` to generate a lot of combinations the
|
73
|
+
easy way. An example:
|
34
74
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'some text'
|
39
|
-
end
|
75
|
+
```ruby
|
76
|
+
require 'ostruct'
|
77
|
+
require 'regtest'
|
40
78
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
79
|
+
o = OpenStruct.new
|
80
|
+
o.a = [1,2,3]
|
81
|
+
o.b = [:x, :y]
|
82
|
+
Regtest.combinations(o).map(&:to_h)
|
83
|
+
# => [{:a=>1, :b=>:x}, {:a=>1, :b=>:y}, {:a=>2, :b=>:x}, {:a=>2, :b=>:y}, {:a=>3, :b=>:x}, {:a=>3, :b=>:y}]
|
84
|
+
```
|
47
85
|
|
48
|
-
|
49
|
-
and the results of the samples (return value of the block) are stored
|
50
|
-
in YAML format. So it should be a YAML friendly value as String,
|
51
|
-
Number, Boolean value, Symbol.
|
52
|
-
Results could also be an Array or Hash with such values.
|
86
|
+
See also the combinations example in the `regtest` folder.
|
53
87
|
|
54
|
-
You can also include Regtest to have the sample method at
|
55
|
-
top level.
|
88
|
+
You can also include `Regtest` to have the `sample` and `combinations method at top level.
|
56
89
|
|
57
|
-
|
58
|
-
|
90
|
+
```ruby
|
91
|
+
require 'regtest'
|
92
|
+
include Regtest
|
59
93
|
|
60
|
-
|
61
|
-
|
62
|
-
|
94
|
+
sample :x do
|
95
|
+
:x
|
96
|
+
end
|
97
|
+
```
|
63
98
|
|
64
|
-
By convention sample files are stored in a directory `regtest`
|
65
|
-
in your Ruby application.
|
99
|
+
By convention sample files are stored in a directory `regtest` in your Ruby application.
|
66
100
|
|
67
101
|
|
68
102
|
### Running Samples
|
69
103
|
|
70
104
|
Whether you run your examples manually
|
71
105
|
|
72
|
-
|
106
|
+
```sh
|
107
|
+
ruby -I lib regtest/*.rb
|
108
|
+
```
|
73
109
|
|
74
|
-
or using the Rake task of regtest
|
75
|
-
Add the line
|
110
|
+
or using the Rake task of regtest and add
|
76
111
|
|
77
|
-
|
112
|
+
```ruby
|
113
|
+
require 'regtest/task'
|
114
|
+
```
|
115
|
+
|
116
|
+
to your `Rakefile` and you can run your samples with `rake regtest`.
|
78
117
|
|
79
|
-
to your Rakefile and you can run your samples with `rake regtest`.
|
80
118
|
|
81
119
|
### Checking Results
|
82
120
|
|
83
|
-
The results of each samples file are stored as a collection of
|
84
|
-
|
85
|
-
|
86
|
-
For example for the samples files
|
121
|
+
The results of each samples file are stored as a collection of YAML documents in
|
122
|
+
a corresponding results file (YAML) per samples file. For example for the
|
123
|
+
samples files
|
87
124
|
|
88
|
-
|
89
|
-
|
125
|
+
```sh
|
126
|
+
regtest/foo.rb
|
127
|
+
regtest/bar.rb
|
128
|
+
```
|
90
129
|
|
91
130
|
are the corresponding results files
|
92
131
|
|
93
|
-
|
94
|
-
|
132
|
+
```sh
|
133
|
+
regtest/foo.yml
|
134
|
+
regtest/bar.yml
|
135
|
+
```
|
95
136
|
|
96
137
|
So the content of the results file of the example above is
|
97
138
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
139
|
+
```yaml
|
140
|
+
---
|
141
|
+
sample: String result
|
142
|
+
result: some text
|
143
|
+
---
|
144
|
+
sample: Division by zero
|
145
|
+
exception: divided by 0
|
146
|
+
```
|
147
|
+
|
148
|
+
Note: Each sample is represented by a YAML document in the corresponding YAML
|
149
|
+
file.
|
150
|
+
|
151
|
+
Each time you run one ore more samples file the corresponding results file will
|
152
|
+
be overwritten (or generated if not yet existent) with the actual result values
|
153
|
+
of your samples. So Source Code Version Control program is the tool to
|
154
|
+
determine changes between older runs of the samples. Therefore the samples file
|
155
|
+
and their corresponding results files should be taken under version control.
|
156
|
+
|
157
|
+
|
158
|
+
## Further information
|
159
|
+
|
160
|
+
I use `regtest` in my project [scripref](https://github.com/janfri/scripref) to
|
161
|
+
generate a lot of malformed input data to check regressions in the behaviour of
|
162
|
+
the parser and text processor.
|
163
|
+
|
164
|
+
A little different is the usage in my projects
|
165
|
+
[mini_exiftool](https://github.com/janfri/mini_exiftool/tree/master/regtest) and
|
166
|
+
[multi_exiftool](https://github.com/janfri/multi_exiftool-redesign/tree/master/regtest).
|
167
|
+
There regtest is used for integration testing to check if Exiftool itself (an
|
168
|
+
external program that I do not develop) returns different values or new tags in
|
169
|
+
newer versions.
|
170
|
+
|
112
171
|
|
113
172
|
## Source Code
|
114
173
|
|
115
174
|
The code is hosted on [github](https://github.com/janfri/regtest) and
|
116
|
-
[
|
117
|
-
|
175
|
+
[bitbucket](https://bitbucket.org/janfri/regtest) Change it to your needs.
|
176
|
+
Release a fork. It is open source.
|
118
177
|
|
119
178
|
## Author
|
120
179
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
require 'rim/tire'
|
2
5
|
require 'rim/regtest'
|
3
6
|
require 'rim/version'
|
@@ -7,12 +10,23 @@ require 'regtest/task'
|
|
7
10
|
|
8
11
|
Rim.setup do |p|
|
9
12
|
p.name = 'regtest'
|
10
|
-
p.version = '0.
|
13
|
+
p.version = '1.0.0'
|
11
14
|
p.authors = 'Jan Friedrich'
|
12
15
|
p.email = 'janfri26@gmail.com'
|
13
|
-
p.summary = '
|
16
|
+
p.summary = 'Simple regression testing for Ruby projects.'
|
14
17
|
p.license = 'Ruby'
|
15
|
-
p.description =
|
18
|
+
p.description = <<-END.gsub(/^ +/, '')
|
19
|
+
This library support a very simple way to do regression testing in Ruby
|
20
|
+
projects. You write Ruby scripts with samples. Run these and get the sample
|
21
|
+
results as YAML output besides your scripts. Check both the scripts and the YAML
|
22
|
+
files with the results in you Source Code Control System. When you run the
|
23
|
+
scrips on a later (or even previous) version of your code a simple diff show you
|
24
|
+
if and how the changes in your code impact the results of your samples.
|
25
|
+
|
26
|
+
This is not a replacement for unit testing but a complement: You can produce a
|
27
|
+
lot of samples with a small amount of Ruby code (e.g. a large number of
|
28
|
+
combinations of data).
|
29
|
+
END
|
16
30
|
p.homepage = 'https://github.com/janfri/regtest'
|
17
31
|
end
|
18
32
|
|
data/lib/regtest.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
1
3
|
#
|
2
4
|
# Regtest - Simple Regression Testing For Ruby Projects
|
3
5
|
#
|
4
|
-
# Copyright 2014, 2015 by Jan Friedrich
|
6
|
+
# Copyright 2014, 2015 by Jan Friedrich <janfri26@gmail.com>
|
5
7
|
# License: Regtest is licensed under the same terms as Ruby itself.
|
6
8
|
#
|
7
9
|
|
data/lib/regtest/task.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# Copyright 2014, 2016 by Jan Friedrich <janfri26@gmail.com>
|
5
|
+
# License: Regtest is licensed under the same terms as Ruby itself.
|
6
|
+
#
|
7
|
+
|
1
8
|
REGTEST_FILES_RB = FileList.new('regtest/**/*.rb')
|
2
9
|
REGTEST_FILES_YML = FileList.new('regtest/**/*.yml')
|
3
10
|
REGTEST_FILES = REGTEST_FILES_RB + REGTEST_FILES_YML
|
data/regtest.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: regtest 1.0.0 ruby lib
|
3
|
+
#
|
4
|
+
# This file is automatically generated by rim.
|
5
|
+
# PLEASE DO NOT EDIT IT DIRECTLY!
|
6
|
+
# Change the values in Rim.setup in Rakefile instead.
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "regtest"
|
10
|
+
s.version = "1.0.0"
|
11
|
+
|
12
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.authors = ["Jan Friedrich"]
|
15
|
+
s.date = "2017-08-19"
|
16
|
+
s.description = "This library support a very simple way to do regression testing in Ruby\nprojects. You write Ruby scripts with samples. Run these and get the sample\nresults as YAML output besides your scripts. Check both the scripts and the YAML\nfiles with the results in you Source Code Control System. When you run the\nscrips on a later (or even previous) version of your code a simple diff show you\nif and how the changes in your code impact the results of your samples.\n\nThis is not a replacement for unit testing but a complement: You can produce a\nlot of samples with a small amount of Ruby code (e.g. a large number of\ncombinations of data).\n"
|
17
|
+
s.email = "janfri26@gmail.com"
|
18
|
+
s.files = ["Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/task.rb", "regtest.gemspec", "regtest/combinations.rb", "regtest/combinations.yml", "regtest/example.rb", "regtest/example.yml", "regtest/no_samples.rb"]
|
19
|
+
s.homepage = "https://github.com/janfri/regtest"
|
20
|
+
s.licenses = ["Ruby"]
|
21
|
+
s.rubygems_version = "2.6.12"
|
22
|
+
s.summary = "Simple regression testing for Ruby projects."
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
s.specification_version = 4
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_development_dependency(%q<rim>, ["~> 2.11"])
|
29
|
+
s.add_development_dependency(%q<regtest>, ["~> 0.4"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<rim>, ["~> 2.11"])
|
32
|
+
s.add_dependency(%q<regtest>, ["~> 0.4"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<rim>, ["~> 2.11"])
|
36
|
+
s.add_dependency(%q<regtest>, ["~> 0.4"])
|
37
|
+
end
|
38
|
+
end
|
data/regtest/combinations.rb
CHANGED
data/regtest/example.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Friedrich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rim
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: regtest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,17 +38,30 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.4'
|
41
|
-
description:
|
41
|
+
description: |
|
42
|
+
This library support a very simple way to do regression testing in Ruby
|
43
|
+
projects. You write Ruby scripts with samples. Run these and get the sample
|
44
|
+
results as YAML output besides your scripts. Check both the scripts and the YAML
|
45
|
+
files with the results in you Source Code Control System. When you run the
|
46
|
+
scrips on a later (or even previous) version of your code a simple diff show you
|
47
|
+
if and how the changes in your code impact the results of your samples.
|
48
|
+
|
49
|
+
This is not a replacement for unit testing but a complement: You can produce a
|
50
|
+
lot of samples with a small amount of Ruby code (e.g. a large number of
|
51
|
+
combinations of data).
|
42
52
|
email: janfri26@gmail.com
|
43
53
|
executables: []
|
44
54
|
extensions: []
|
45
55
|
extra_rdoc_files: []
|
46
56
|
files:
|
47
57
|
- Changelog
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE
|
48
60
|
- README.md
|
49
61
|
- Rakefile
|
50
62
|
- lib/regtest.rb
|
51
63
|
- lib/regtest/task.rb
|
64
|
+
- regtest.gemspec
|
52
65
|
- regtest/combinations.rb
|
53
66
|
- regtest/combinations.yml
|
54
67
|
- regtest/example.rb
|
@@ -74,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
87
|
version: '0'
|
75
88
|
requirements: []
|
76
89
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.6.12
|
78
91
|
signing_key:
|
79
92
|
specification_version: 4
|
80
|
-
summary:
|
93
|
+
summary: Simple regression testing for Ruby projects.
|
81
94
|
test_files: []
|