cornucopia 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/cornucopia.gemspec +1 -1
- data/lib/cornucopia/rspec_hooks.rb +7 -1
- data/lib/cornucopia/util/configuration.rb +17 -0
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/util/configuration_spec.rb +16 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e688f9aceb220bfa0a6c2af814d686e15a9171d
|
4
|
+
data.tar.gz: fc462ae7b366802e45b6b8b4a31ea4c8f963b32d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10924bc983cba01bad63bf9286479fb8bf401336312e4f3589ac0d8e868454c1e002f7886215b311444e5ab4813406fad9a7495358679238e6841e73ee1ee7af
|
7
|
+
data.tar.gz: 82e3138fe83a8d88ddc90c50f4444cc4558bbedf65acacaf749e5b1da252ae5c39404aa3fdeea3ca350df7a446799de9a72c40a662814e197eb85d2e57c809e0
|
data/README.md
CHANGED
@@ -301,6 +301,19 @@ The configuration class contains the various configurations that are used by the
|
|
301
301
|
The seed value represents the seed value for `rand`. It is used by the testing hooks to allow tests with
|
302
302
|
randomized values to still be repeatable. This value can be set or read.
|
303
303
|
|
304
|
+
* **context_seed**
|
305
|
+
|
306
|
+
The context_seed value represents the seed value for `rand` if called outside of a test within a group.
|
307
|
+
It is used by the testing hooks to allow tests with randomized values to still be repeatable.
|
308
|
+
This value can be set or read.
|
309
|
+
|
310
|
+
* **suite_seed**
|
311
|
+
|
312
|
+
The seed value represents the seed value for `rand`. It is used by the testing hooks to allow
|
313
|
+
test runs to be re-run with the same seed for the entire run. It should make
|
314
|
+
randomized values including the context and seed values to still be repeatable.
|
315
|
+
This value can be set or read.
|
316
|
+
|
304
317
|
* **order_seed**
|
305
318
|
|
306
319
|
**Experimental** The order_seed value represents the seed value for the order that RSpec tests are run in if they
|
data/cornucopia.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency "activesupport", "
|
25
|
+
spec.add_dependency "activesupport", "< 5.0"
|
26
26
|
|
27
27
|
spec.add_development_dependency "rails"
|
28
28
|
# spec.add_development_dependency "mysql2"
|
@@ -11,6 +11,7 @@ module Cornucopia
|
|
11
11
|
include Singleton
|
12
12
|
|
13
13
|
attr_accessor :last_reported_example
|
14
|
+
attr_accessor :suite_seed_value
|
14
15
|
attr_accessor :context_seed_value
|
15
16
|
attr_accessor :seed_value
|
16
17
|
|
@@ -23,7 +24,7 @@ module Cornucopia
|
|
23
24
|
if (example.exception)
|
24
25
|
@last_reported_example = example
|
25
26
|
|
26
|
-
puts("random seed for testing was: #{context_seed_value}, #{seed_value}")
|
27
|
+
puts("random seed for testing was: #{suite_seed_value}, #{context_seed_value}, #{seed_value}")
|
27
28
|
|
28
29
|
Cornucopia::Util::ReportBuilder.current_report.
|
29
30
|
within_section("Test Error: #{example.full_description}") do |report|
|
@@ -56,6 +57,11 @@ RSpec.configure do |config|
|
|
56
57
|
puts "Cornucopia::Hook::suite end" if Cornucopia::Util::Configuration.benchmark
|
57
58
|
|
58
59
|
Cornucopia::Util::ReportBuilder.current_report.close
|
60
|
+
|
61
|
+
Cornucopia::RSpecHelper.instance.suite_seed_value = Cornucopia::Util::Configuration.suite_seed ||
|
62
|
+
100000000000000000000000000000000000000 + Random.new.rand(899999999999999999999999999999999999999)
|
63
|
+
|
64
|
+
srand(Cornucopia::RSpecHelper.instance.suite_seed_value)
|
59
65
|
end
|
60
66
|
|
61
67
|
puts "Cornucopia::Hook::suite end time: #{time}" if Cornucopia::Util::Configuration.benchmark
|
@@ -18,6 +18,7 @@ module Cornucopia
|
|
18
18
|
configurations.order_seed = nil
|
19
19
|
configurations.rand_seed = nil
|
20
20
|
configurations.rand_context_seed = nil
|
21
|
+
configurations.rand_suite_seed = nil
|
21
22
|
configurations.user_log_files = {}
|
22
23
|
configurations.default_num_lines = 500
|
23
24
|
configurations.grab_logs = true
|
@@ -51,6 +52,7 @@ module Cornucopia
|
|
51
52
|
:example,
|
52
53
|
:seeds__seed_value,
|
53
54
|
:seeds__context_seed_value,
|
55
|
+
:seeds__suite_seed_value,
|
54
56
|
:example__example_group_instance,
|
55
57
|
:example__metadata__caller,
|
56
58
|
{
|
@@ -387,6 +389,21 @@ module Cornucopia
|
|
387
389
|
Cornucopia::Util::Configuration.instance.configurations.rand_context_seed
|
388
390
|
end
|
389
391
|
|
392
|
+
# rand_suite_seed is the seed value used to seed the srand function at the start of a context.
|
393
|
+
# This is done to allow tests with random elements in them to be repeatable.
|
394
|
+
# If a test fails, simply set Cornucopia::Util::Configuration.rand_suite_seed to the
|
395
|
+
# value of the failed tests suite_seed value (output in the stdout and the generated report)
|
396
|
+
# and run the test again. This should re-run the exact same test, resulting in a
|
397
|
+
# repeatable test even with randomization in it.
|
398
|
+
def suite_seed=(value)
|
399
|
+
Cornucopia::Util::Configuration.instance.configurations.rand_suite_seed = value
|
400
|
+
srand(value) if value
|
401
|
+
end
|
402
|
+
|
403
|
+
def suite_seed
|
404
|
+
Cornucopia::Util::Configuration.instance.configurations.rand_suite_seed
|
405
|
+
end
|
406
|
+
|
390
407
|
# order_seed is the seed value used to set the order that randomly ordered tests are run in.
|
391
408
|
# This is provided as a convenience method. I think it is easier to set this in rails_helper than it is to
|
392
409
|
# set it on the command line. This also provides a uniform method to do it.
|
data/lib/cornucopia/version.rb
CHANGED
@@ -36,6 +36,22 @@ describe "Cornucopia::Util::Configuration" do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
it "has a default suite_seed value" do
|
40
|
+
expect(Cornucopia::Util::Configuration.suite_seed).not_to be
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can set the suite_seed value" do
|
44
|
+
begin
|
45
|
+
suite_seed_value = rand(0..999999999999999999999999999)
|
46
|
+
|
47
|
+
Cornucopia::Util::Configuration.suite_seed = suite_seed_value
|
48
|
+
|
49
|
+
expect(Cornucopia::Util::Configuration.suite_seed).to be == suite_seed_value
|
50
|
+
ensure
|
51
|
+
Cornucopia::Util::Configuration.suite_seed = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
39
55
|
it "has a default order_seed value" do
|
40
56
|
expect(Cornucopia::Util::Configuration.order_seed).not_to be
|
41
57
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cornucopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
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: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|