simmer 1.0.0.pre.alpha.8 → 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/README.md +21 -6
- data/lib/simmer/externals/file_system.rb +1 -1
- data/lib/simmer/externals/mysql_database.rb +3 -3
- data/lib/simmer/externals/{mysql_database → sql_writers}/sql_fixture.rb +3 -3
- data/lib/simmer/judge.rb +1 -5
- data/lib/simmer/runner.rb +7 -3
- data/lib/simmer/suite.rb +3 -1
- data/lib/simmer/util/yaml_reader.rb +1 -1
- data/lib/simmer/version.rb +1 -1
- data/lib/simmer.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7988189a0fd02e4ec9231a3ddb8e8e7e27682cdc2ae3625bc1d0bd6ddc6d1379
|
4
|
+
data.tar.gz: f5fcd321056010f74a87ad4d76337920616c6564c9d74eb7c6bbd4acdd6a0e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3122824cd6ed5c9480f148cb86e8cc9403aa6b54013424ca50cfd69bd881577b83c1b79acd4b710664ab033f1ee83211b517c2df43f23d29299ac9d5f01ce885
|
7
|
+
data.tar.gz: 369bccc61afbb3d4246d9b9baa49915372e3276a9bbe5ae530108046d9912ef5dffa5f1f416f7cf0d0f00781e7bb175b0aeedc6ec541a276e418bad51e2cf95f
|
data/README.md
CHANGED
@@ -76,15 +76,23 @@ spoon_client:
|
|
76
76
|
# secret_access_key:
|
77
77
|
````
|
78
78
|
|
79
|
+
Note: You can configure any options for `mysql_database` listed in the [mysql2 gem configuration options](https://github.com/brianmario/mysql2#connection-options).
|
80
|
+
|
79
81
|
Fill out the missing configuration values required for each section. If you would like to use your local file system then un-comment the `local_file_system` key. If you would like to use AWS S3 then un-comment out the `aws_file_system` key.
|
80
82
|
|
83
|
+
Note: There is a naming-convention-based protection to help ensure non-test database and file systems do not get accidentally wiped that you must follow:
|
84
|
+
|
85
|
+
1. Database names must end in `_test'
|
86
|
+
2. local file system dir must end in `-test`
|
87
|
+
3. AWS file system bucket must end in `-test`
|
88
|
+
|
81
89
|
### Simmer Directory
|
82
90
|
|
83
91
|
You will also need to create the following folder structure in your project's root folder:
|
84
92
|
|
85
93
|
* **simmer/files**: Place any files necessary to stage in this directory.
|
86
|
-
* **simmer/fixtures**: Place
|
87
|
-
* **simmer/specs**: Place specification
|
94
|
+
* **simmer/fixtures**: Place YAML files, that describe database records, necessary to stage the database.
|
95
|
+
* **simmer/specs**: Place specification YAML files here.
|
88
96
|
|
89
97
|
It does not matter how each of these directories are internally structured, they can contain folder structure in any arbitrary way. These directories should be version controlled as they contain the necessary information to execute your tests. But you may want to ignore the `simmer/results` directory as that will store the results after execution.
|
90
98
|
|
@@ -158,9 +166,14 @@ Each file entry specifies two things:
|
|
158
166
|
|
159
167
|
###### Fixtures
|
160
168
|
|
161
|
-
|
169
|
+
Fixtures will populate the database specified in the `mysql_database` section of `simmer.yaml`. In order to do this you need to:
|
162
170
|
|
163
|
-
|
171
|
+
1. Add the fixture to a YAML file in the `simmer/fixtures` directory.
|
172
|
+
2. Add the name of the fixture you wish to use in the `stage/fixtures` section as illustrated above
|
173
|
+
|
174
|
+
**Adding Fixtures**
|
175
|
+
|
176
|
+
Fixtures live in YAML files within the `simmer/fixtures` directory. They can be placed in any arbitrary file, the only restriction is their top-level keys that uniquely identify a fixture. Here is an example of a fixture file:
|
164
177
|
|
165
178
|
````yaml
|
166
179
|
hulk:
|
@@ -178,7 +191,7 @@ iron_man:
|
|
178
191
|
last: CLASSIFIED
|
179
192
|
````
|
180
193
|
|
181
|
-
This example specifies two fixtures: `hulk` and `iron_man`. Each will end up creating a record in the `agents` table with their respective attributes (columns.
|
194
|
+
This example specifies two fixtures: `hulk` and `iron_man`. Each will end up creating a record in the `agents` table with their respective attributes (columns).
|
182
195
|
|
183
196
|
##### Act Section
|
184
197
|
|
@@ -224,7 +237,9 @@ This contains two table and one output assertion. It explicitly states that:
|
|
224
237
|
|
225
238
|
* The table `agents` should exactly contain two records with the column values as described (iron_man and hulk)
|
226
239
|
* The table `agents` should include a record where the last name is `stark`
|
227
|
-
* The output should contain the string described in the value somewhere in the log
|
240
|
+
* The standard output should contain the string described in the value somewhere in the log
|
241
|
+
|
242
|
+
**Note**: Output does not currently test the standard error, just the standard output.
|
228
243
|
|
229
244
|
###### Table Assertion Rules
|
230
245
|
|
@@ -7,13 +7,13 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative 'sql_writers/sql_fixture'
|
11
11
|
|
12
12
|
module Simmer
|
13
13
|
module Externals
|
14
14
|
# Provides a wrapper around mysql2 for Simmer.
|
15
15
|
class MysqlDatabase
|
16
|
-
DATABASE_SUFFIX = '
|
16
|
+
DATABASE_SUFFIX = '_test'
|
17
17
|
|
18
18
|
def initialize(client, exclude_tables = [])
|
19
19
|
@client = client
|
@@ -57,7 +57,7 @@ module Simmer
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def seed_sql_statements(fixtures)
|
60
|
-
fixtures.map { |fixture| SqlFixture.new(client, fixture).to_sql }
|
60
|
+
fixtures.map { |fixture| SqlWriters::SqlFixture.new(client, fixture).to_sql }
|
61
61
|
end
|
62
62
|
|
63
63
|
def clean_sql_statements
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
module Simmer
|
11
11
|
module Externals
|
12
|
-
|
12
|
+
module SqlWriters
|
13
13
|
# This class knows how to turn a fixture into sql.
|
14
14
|
class SqlFixture
|
15
15
|
extend Forwardable
|
@@ -28,10 +28,10 @@ module Simmer
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_sql
|
31
|
-
sql_columns = fields.keys.join(',')
|
31
|
+
sql_columns = fields.keys.map { |k| "`#{k}`" }.join(',')
|
32
32
|
sql_values = fields.values.map { |v| "'#{client.escape(v.to_s)}'" }.join(',')
|
33
33
|
|
34
|
-
"INSERT INTO
|
34
|
+
"INSERT INTO `#{table}` (#{sql_columns}) VALUES (#{sql_values})"
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
data/lib/simmer/judge.rb
CHANGED
@@ -26,11 +26,7 @@ module Simmer
|
|
26
26
|
def assert(specification, output)
|
27
27
|
assertions = specification.assert.assertions
|
28
28
|
|
29
|
-
bad_assertions = assertions.
|
30
|
-
bad_assert = assertion.assert(database, output)
|
31
|
-
|
32
|
-
memo << bad_assert if bad_assert
|
33
|
-
end
|
29
|
+
bad_assertions = assertions.map { |assertion| assertion.assert(database, output) }.compact
|
34
30
|
|
35
31
|
Result.new(bad_assertions)
|
36
32
|
end
|
data/lib/simmer/runner.rb
CHANGED
@@ -37,7 +37,7 @@ module Simmer
|
|
37
37
|
judge_result = assert(specification, spoon_client_result)
|
38
38
|
|
39
39
|
Result.new(id, judge_result, specification, spoon_client_result).tap do |result|
|
40
|
-
msg = result
|
40
|
+
msg = pass_message(result)
|
41
41
|
print_waiting('Done', 'Final verdict')
|
42
42
|
print(msg)
|
43
43
|
end
|
@@ -85,7 +85,7 @@ module Simmer
|
|
85
85
|
def execute_spoon(specification, config)
|
86
86
|
print_waiting('Act', 'Executing Spoon')
|
87
87
|
spoon_client_result = spoon_client.run(specification, config)
|
88
|
-
msg = spoon_client_result
|
88
|
+
msg = pass_message(spoon_client_result)
|
89
89
|
print(msg)
|
90
90
|
|
91
91
|
spoon_client_result
|
@@ -101,7 +101,7 @@ module Simmer
|
|
101
101
|
|
102
102
|
output = spoon_client_result.execution_result.out
|
103
103
|
judge_result = judge.assert(specification, output)
|
104
|
-
msg = judge_result
|
104
|
+
msg = pass_message(judge_result)
|
105
105
|
|
106
106
|
print(msg)
|
107
107
|
|
@@ -125,5 +125,9 @@ module Simmer
|
|
125
125
|
|
126
126
|
"#{msg}#{char * missing}"
|
127
127
|
end
|
128
|
+
|
129
|
+
def pass_message(obj)
|
130
|
+
obj.pass? ? 'Pass' : 'Fail'
|
131
|
+
end
|
128
132
|
end
|
129
133
|
end
|
data/lib/simmer/suite.rb
CHANGED
@@ -13,6 +13,8 @@ require_relative 'suite/result'
|
|
13
13
|
module Simmer
|
14
14
|
# Runs a collection of specifications and then writes down the results to disk.
|
15
15
|
class Suite
|
16
|
+
LINE_LENGTH = 80
|
17
|
+
|
16
18
|
def initialize(
|
17
19
|
config:,
|
18
20
|
out:,
|
@@ -73,7 +75,7 @@ module Simmer
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def print_line
|
76
|
-
out.puts('-' *
|
78
|
+
out.puts('-' * LINE_LENGTH)
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
data/lib/simmer/version.rb
CHANGED
data/lib/simmer.rb
CHANGED
@@ -39,7 +39,7 @@ require_relative 'simmer/suite'
|
|
39
39
|
|
40
40
|
# The main entry-point API for the library.
|
41
41
|
module Simmer
|
42
|
-
DEFAULT_CONFIG_PATH = File.join('config', 'simmer.yaml')
|
42
|
+
DEFAULT_CONFIG_PATH = File.join('config', 'simmer.yaml').freeze
|
43
43
|
DEFAULT_SIMMER_DIR = 'simmer'
|
44
44
|
|
45
45
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -226,9 +226,9 @@ files:
|
|
226
226
|
- lib/simmer/externals/file_system.rb
|
227
227
|
- lib/simmer/externals/local_file_system.rb
|
228
228
|
- lib/simmer/externals/mysql_database.rb
|
229
|
-
- lib/simmer/externals/mysql_database/sql_fixture.rb
|
230
229
|
- lib/simmer/externals/spoon_client.rb
|
231
230
|
- lib/simmer/externals/spoon_client/result.rb
|
231
|
+
- lib/simmer/externals/sql_writers/sql_fixture.rb
|
232
232
|
- lib/simmer/judge.rb
|
233
233
|
- lib/simmer/judge/result.rb
|
234
234
|
- lib/simmer/runner.rb
|
@@ -275,9 +275,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
275
275
|
version: '2.5'
|
276
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
277
|
requirements:
|
278
|
-
- - "
|
278
|
+
- - ">="
|
279
279
|
- !ruby/object:Gem::Version
|
280
|
-
version:
|
280
|
+
version: '0'
|
281
281
|
requirements: []
|
282
282
|
rubygems_version: 3.0.3
|
283
283
|
signing_key:
|