marsh_grass 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/lib/marsh_grass/rspec.rb +149 -0
- data/lib/marsh_grass/version.rb +5 -0
- data/lib/marsh_grass.rb +7 -0
- data/marsh_grass.gemspec +38 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94c562ed414ec9c4d7f9d7801f3e783d3e7f1d08
|
4
|
+
data.tar.gz: 954768dee75685d72489a712810651e9ae6a66f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44aeb6bb84714c4adb13ab9c1611e0692e75994efb662e4a9c21f133de8554001c2fcb69b7256d755daa299545b48c05b89a8c3c99a67f081907830ef51d4d61
|
7
|
+
data.tar.gz: d83206174d904b9af43b49c7584ed7f7093b3c2ef467f81390cf28bfcb29c757d5e43eb6432c8dd9cb261086016415f07dbd0fe317423cc555f130a92f855a0e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Wes Rich
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# MarshGrass
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/marsh_grass`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'marsh_grass'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install marsh_grass
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wesrich/marsh_grass.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'timecop'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
def untag_example(example, tag)
|
9
|
+
example.example_group.metadata.delete(tag) if example.metadata[:turnip]
|
10
|
+
example.metadata.delete(tag)
|
11
|
+
end
|
12
|
+
|
13
|
+
config.around(time_of_day: true) do |original_example|
|
14
|
+
now = Time.now
|
15
|
+
time_of_day = untag_example(original_example, :time_of_day)
|
16
|
+
test_segments = time_of_day.is_a?(Array) ? time_of_day : [time_of_day]
|
17
|
+
test_segments = [:hours] if test_segments == [true]
|
18
|
+
hours_to_run = test_segments.include?(:hours) ? (0..23) : [now.hour]
|
19
|
+
minutes_to_run = test_segments.include?(:minutes) ? (0..59) : [now.min]
|
20
|
+
seconds_to_run = test_segments.include?(:seconds) ? (0..59) : [now.sec]
|
21
|
+
|
22
|
+
total = hours_to_run.size * minutes_to_run.size * seconds_to_run.size
|
23
|
+
|
24
|
+
def describe_time_of_day(test, hour, minute, second)
|
25
|
+
test.metadata[:description] = "Run Time #{hour}:#{minute}:#{second}: #{test.metadata[:description]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
run_count = 0
|
29
|
+
hours_to_run.each do |hour|
|
30
|
+
minutes_to_run.each do |minute|
|
31
|
+
seconds_to_run.each do |second|
|
32
|
+
run_count += 1
|
33
|
+
# Freeze time at the specified hour, minute, and/or second.
|
34
|
+
# We need to run the test within the Timecop.freeze block,
|
35
|
+
# in order to actually be affected by Timecop.
|
36
|
+
Timecop.freeze(now.year, now.month, now.day, hour, minute, second) do
|
37
|
+
# Let the original example be the final repetition
|
38
|
+
last_run = run_count == total
|
39
|
+
example = last_run ? original_example : original_example.duplicate_with
|
40
|
+
# Run example with a helpful description
|
41
|
+
describe_time_of_day(example, hour, minute, second)
|
42
|
+
example.run(original_example.example_group_instance, original_example.reporter)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
config.around(surrounding_time: true) do |original_example|
|
50
|
+
now = Time.now
|
51
|
+
surrounding_time = untag_example(original_example, :surrounding_time)
|
52
|
+
hour = surrounding_time.fetch(:hour, now.hour)
|
53
|
+
minute = surrounding_time.fetch(:minute, now.min)
|
54
|
+
second = surrounding_time.fetch(:second, now.sec)
|
55
|
+
# 1000 milliseconds before & after the surrounding time
|
56
|
+
test_time_float = Time.local(now.year, now.month, now.day, hour, minute, second).to_f
|
57
|
+
|
58
|
+
def describe_exact_time(test, time)
|
59
|
+
test.metadata[:description] = "Run Time #{time.strftime('%H:%M:%S:%L')}: #{test.metadata[:description]}"
|
60
|
+
end
|
61
|
+
|
62
|
+
(-1000..1000).each do |millisecond|
|
63
|
+
# Travel to the specified hour, minute, second, and millisecond, allowing
|
64
|
+
# for time to elapse.
|
65
|
+
# We need to run the test within the Timecop.freeze block,
|
66
|
+
# in order to actually be affected by Timecop.
|
67
|
+
test_time = Time.at(test_time_float + millisecond.to_f / 1000)
|
68
|
+
Timecop.travel(test_time) do
|
69
|
+
# Let the original example be the final repetition
|
70
|
+
last_run = millisecond == 1000
|
71
|
+
example = last_run ? original_example : original_example.duplicate_with
|
72
|
+
# Run example with a helpful description
|
73
|
+
describe_exact_time(example, test_time)
|
74
|
+
example.run(original_example.example_group_instance, original_example.reporter)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
config.around(elapsed_time: true) do |original_example|
|
80
|
+
def describe_time_elapsed(test, scale)
|
81
|
+
test.metadata[:description] = "Run Speed #{scale}x Slower: #{test.metadata[:description]}"
|
82
|
+
end
|
83
|
+
|
84
|
+
# Freeze time at the specified hour, minute, and/or second.
|
85
|
+
# We need to run the test within the Timecop.freeze block,
|
86
|
+
# in order to actually be affected by Timecop.
|
87
|
+
time_multipliers = untag_example(original_example, :elapsed_time)
|
88
|
+
time_multipliers = (1..10) unless time_multipliers.respond_to?(:each)
|
89
|
+
time_multipliers.each do |seconds_multiplier|
|
90
|
+
Timecop.scale(seconds_multiplier) do
|
91
|
+
# Let the original example be the final repetition
|
92
|
+
last_run = seconds_multiplier == time_multipliers.last
|
93
|
+
example = last_run ? original_example : original_example.duplicate_with
|
94
|
+
# Run example with a helpful description
|
95
|
+
describe_time_elapsed(example, seconds_multiplier)
|
96
|
+
example.run(original_example.example_group_instance, original_example.reporter)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
config.around(time_zones: true) do |original_example|
|
102
|
+
untag_example(original_example, :time_zones)
|
103
|
+
|
104
|
+
utc = Time.now.utc
|
105
|
+
time_zone_hours = %w[-12 -11 -10 -09 -08 -07 -06 -05 -04 -03 -02 -01 +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +10 +11 +12 +13 +14]
|
106
|
+
time_zone_minutes = %w[00 30]
|
107
|
+
|
108
|
+
def describe_time_zone(test, time_zone_hour, time_zone_minute)
|
109
|
+
test.metadata[:description] = "Time Zone Offset #{time_zone_hour}:#{time_zone_minute}: #{test.metadata[:description]}"
|
110
|
+
end
|
111
|
+
|
112
|
+
total = time_zone_hours.size * time_zone_minutes.size
|
113
|
+
|
114
|
+
time_zone_hours.each.with_index do |time_zone_hour, hour_index|
|
115
|
+
time_zone_minutes.each.with_index(1) do |time_zone_minute, minute_index|
|
116
|
+
adjustment = "#{time_zone_hour}:#{time_zone_minute}"
|
117
|
+
adjusted_time = Time.new(utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec, adjustment)
|
118
|
+
# We need to run the test within the Timecop.freeze block,
|
119
|
+
# in order to actually be affected by Timecop.
|
120
|
+
Timecop.travel(adjusted_time) do
|
121
|
+
# Let the original example be the final repetition
|
122
|
+
last_run = (hour_index * 2) + minute_index == total
|
123
|
+
example = last_run ? original_example : original_example.duplicate_with
|
124
|
+
# Run example with a helpful description
|
125
|
+
describe_time_zone(example, time_zone_hour, time_zone_minute)
|
126
|
+
example.run(original_example.example_group_instance, original_example.reporter)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
config.around(repetitions: true) do |original_example|
|
133
|
+
repetitions = untag_example(original_example, :repetitions)
|
134
|
+
total = repetitions.is_a?(Integer) ? repetitions : 1000
|
135
|
+
|
136
|
+
def describe_repetition_count(test, count, total)
|
137
|
+
test.metadata[:description] = "Repetition #{count} of #{total}: #{test.metadata[:description]}"
|
138
|
+
end
|
139
|
+
|
140
|
+
(1..total).each do |count|
|
141
|
+
# Let the original example be the final repetition
|
142
|
+
last_run = count == total
|
143
|
+
example = last_run ? original_example : original_example.duplicate_with
|
144
|
+
# Run example with a helpful description
|
145
|
+
describe_repetition_count(example, count, total)
|
146
|
+
example.run(original_example.example_group_instance, original_example.reporter)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/lib/marsh_grass.rb
ADDED
data/marsh_grass.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# coding: utf-8
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'marsh_grass/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'marsh_grass'
|
10
|
+
spec.version = MarshGrass::VERSION
|
11
|
+
spec.authors = [
|
12
|
+
'Wes Rich',
|
13
|
+
'Amanda Simon'
|
14
|
+
]
|
15
|
+
spec.email = [
|
16
|
+
'wes.rich@rolemodelsoftware.com',
|
17
|
+
'amanda.simon@rolemodelsoftware.com'
|
18
|
+
]
|
19
|
+
|
20
|
+
spec.summary = %q{A set of tools to help diagnose random test failures.}
|
21
|
+
spec.description = %q{Currently works with RSpec tags to run against possible test failure scenarios.}
|
22
|
+
spec.homepage = ""
|
23
|
+
spec.license = 'MIT'
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = 'exe'
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'pry-byebug', '~> 3'
|
35
|
+
spec.add_development_dependency 'pry-doc', '~> 0'
|
36
|
+
spec.add_dependency 'rspec', '~> 3.6'
|
37
|
+
spec.add_dependency 'timecop', '~> 0'
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: marsh_grass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wes Rich
|
8
|
+
- Amanda Simon
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.15'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.15'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: pry-byebug
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry-doc
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.6'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.6'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: timecop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
description: Currently works with RSpec tags to run against possible test failure
|
99
|
+
scenarios.
|
100
|
+
email:
|
101
|
+
- wes.rich@rolemodelsoftware.com
|
102
|
+
- amanda.simon@rolemodelsoftware.com
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".gitignore"
|
108
|
+
- ".rspec"
|
109
|
+
- ".travis.yml"
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- lib/marsh_grass.rb
|
115
|
+
- lib/marsh_grass/rspec.rb
|
116
|
+
- lib/marsh_grass/version.rb
|
117
|
+
- marsh_grass.gemspec
|
118
|
+
homepage: ''
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.6.13
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: A set of tools to help diagnose random test failures.
|
142
|
+
test_files: []
|