ice_age 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/lib/ice_age/version.rb +1 -1
- data/lib/ice_age.rb +1 -2
- metadata +16 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7276aef4fd57579f60d778064a82a3a0eb71b3392c25f590ae73b0497d3857f1
|
|
4
|
+
data.tar.gz: f0d4c7cf0ace0b56ab46cb5625cfafdf52ec130b29cf70682c659186a2a4d66e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ecf655a96c47c7d7a96ae92cff272ac5df1deb958edbf8e855a6fa6e0bb4dc9613c8c288724510e66869809ffa7679252b197df3c8df111b5e4b08fb2db8f74
|
|
7
|
+
data.tar.gz: b15f8878442a7ebc63a6bca1902641db99d88a8b0a5b82cfb49fb8e416640efda4a952d2738668d1cce80c5333e8d08650d2fd03fbbe0ea4f216e32235b3612c
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
### v0.2.1 (2026-11-27)
|
|
2
|
+
- Requires Ruby 3.3 or newer.
|
|
3
|
+
- `endure!` detects deleted ENV variables.
|
|
4
|
+
|
|
5
|
+
### v0.2.0 (2021-04-01)
|
|
6
|
+
- whitelist pry commands
|
|
7
|
+
- module conversion
|
|
8
|
+
|
|
9
|
+
### v0.1.3 (2020-12-16)
|
|
10
|
+
- code cleaup
|
|
11
|
+
- codecov
|
|
12
|
+
- github-action (#4)
|
|
13
|
+
- improve gemspec
|
|
14
|
+
- upgrade changelog to md format
|
|
15
|
+
- safeguards
|
|
16
|
+
- travis-ci and codecov
|
|
17
|
+
- codebeat
|
|
18
|
+
- move repo: rb_ prefix => _rb suffix
|
|
19
|
+
- put readme usage examle into spec
|
|
20
|
+
|
|
21
|
+
### v0.1.2 (2020-09-28)
|
|
22
|
+
- restore after, not before
|
|
23
|
+
|
|
24
|
+
### v0.1.1 (2020-09-28)
|
|
25
|
+
- delay freeze
|
|
26
|
+
|
|
27
|
+
### v0.1.0 (2020-09-13)
|
|
28
|
+
- freeze immediately
|
|
29
|
+
|
|
30
|
+
### v0.0.2 (2020-09-13)
|
|
31
|
+
- auto freeze during before(:suite)
|
|
32
|
+
- improved endure! msg
|
|
33
|
+
- add examples
|
|
34
|
+
|
|
35
|
+
### v0.0.1 (2020-09-04)
|
|
36
|
+
- initial launch
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Daniel Pepper
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
IceAge
|
|
2
|
+
======
|
|
3
|
+

|
|
4
|
+
[](https://codecov.io/gh/dpep/ice_age_rb)
|
|
5
|
+
|
|
6
|
+
Freeze your ENVironment during testing. ENV is reset after each test, making it trivial to maintain test isolation while testing your code with different environment variable values.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
```ruby
|
|
11
|
+
# Gemfile
|
|
12
|
+
group :test do
|
|
13
|
+
gem 'ice_age'
|
|
14
|
+
end
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
```ruby
|
|
20
|
+
require 'ice_age'
|
|
21
|
+
|
|
22
|
+
describe 'Feature' do
|
|
23
|
+
context 'with new feature enabled' do
|
|
24
|
+
before { ENV['FEATURE_ENABLED'] = 'true' }
|
|
25
|
+
|
|
26
|
+
it { expect(ENV['FEATURE_ENABLED']).to eq 'true' }
|
|
27
|
+
|
|
28
|
+
# run tests against enabled feature
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# ENV resets
|
|
32
|
+
it { expect(ENV['FEATURE_ENABLED']).to be_nil }
|
|
33
|
+
|
|
34
|
+
# run tests when feature is disabled
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
#### Catch ENV changes at load time
|
|
40
|
+
ENV is frozen when the suite starts, so a change made while spec files load (outside a `before` or example block) leaks into every test. To catch these, freeze ENV earlier by requiring `ice_age/freeze` at the top of `spec_helper.rb`:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
require 'ice_age/freeze'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The suite then fails to start, listing each variable that changed after the freeze.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Inglorious Alternatives
|
|
51
|
+
```ruby
|
|
52
|
+
before do
|
|
53
|
+
allow(ENV).to receive(:[]).and_call_original
|
|
54
|
+
allow(ENV).to receive(:[]).with('FEATURE_ENABLED').and_return('true')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
before do
|
|
59
|
+
stub_const('ENV', ENV.to_hash.merge('FEATURE_ENABLED' => 'true'))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
around do |example|
|
|
64
|
+
ENV['FEATURE_ENABLED'] = 'true'
|
|
65
|
+
|
|
66
|
+
example.run
|
|
67
|
+
|
|
68
|
+
ENV['FEATURE_ENABLED'] = nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# https://github.com/thoughtbot/climate_control
|
|
73
|
+
around do |example|
|
|
74
|
+
ClimateControl.modify FEATURE_ENABLED: 'true' do
|
|
75
|
+
example.run
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# https://github.com/ljkbennett/stub_env
|
|
81
|
+
before do
|
|
82
|
+
stub_env('FEATURE_ENABLED', 'true')
|
|
83
|
+
end
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
----
|
data/lib/ice_age/version.rb
CHANGED
data/lib/ice_age.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'ice_age/version'
|
|
2
|
-
require 'set'
|
|
3
2
|
|
|
4
3
|
module IceAge
|
|
5
4
|
extend self
|
|
@@ -23,7 +22,7 @@ module IceAge
|
|
|
23
22
|
def endure!
|
|
24
23
|
raise 'not frozen' unless frozen?
|
|
25
24
|
|
|
26
|
-
changes = (
|
|
25
|
+
changes = (ENV.keys | @env.keys).reject { |k| ENV[k] == @env[k] } - WHITELIST
|
|
27
26
|
unless changes.empty?
|
|
28
27
|
msg = changes.map {|k| { k => { @env[k] => ENV[k] } }}.to_s
|
|
29
28
|
raise 'ENV changed after freeze: ' + msg
|
metadata
CHANGED
|
@@ -1,59 +1,44 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ice_age
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Pepper
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: debug
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: pry
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
18
|
+
version: '1'
|
|
34
19
|
type: :development
|
|
35
20
|
prerelease: false
|
|
36
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
22
|
requirements:
|
|
38
23
|
- - ">="
|
|
39
24
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
25
|
+
version: '1'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
27
|
+
name: rspec
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
44
29
|
requirements:
|
|
45
30
|
- - ">="
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
32
|
+
version: '3.10'
|
|
48
33
|
type: :development
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
37
|
- - ">="
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
39
|
+
version: '3.10'
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec
|
|
41
|
+
name: rspec-debugging
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
58
43
|
requirements:
|
|
59
44
|
- - ">="
|
|
@@ -72,20 +57,22 @@ dependencies:
|
|
|
72
57
|
requirements:
|
|
73
58
|
- - ">="
|
|
74
59
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
60
|
+
version: '1'
|
|
76
61
|
type: :development
|
|
77
62
|
prerelease: false
|
|
78
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
64
|
requirements:
|
|
80
65
|
- - ">="
|
|
81
66
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
67
|
+
version: '1'
|
|
83
68
|
description: Freeze your ENVironment for testing.
|
|
84
|
-
email:
|
|
85
69
|
executables: []
|
|
86
70
|
extensions: []
|
|
87
71
|
extra_rdoc_files: []
|
|
88
72
|
files:
|
|
73
|
+
- CHANGELOG.md
|
|
74
|
+
- LICENSE.txt
|
|
75
|
+
- README.md
|
|
89
76
|
- lib/ice_age.rb
|
|
90
77
|
- lib/ice_age/freeze.rb
|
|
91
78
|
- lib/ice_age/rspec.rb
|
|
@@ -94,7 +81,6 @@ homepage: https://github.com/dpep/ice_age_rb
|
|
|
94
81
|
licenses:
|
|
95
82
|
- MIT
|
|
96
83
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
98
84
|
rdoc_options: []
|
|
99
85
|
require_paths:
|
|
100
86
|
- lib
|
|
@@ -102,15 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
102
88
|
requirements:
|
|
103
89
|
- - ">="
|
|
104
90
|
- !ruby/object:Gem::Version
|
|
105
|
-
version: '
|
|
91
|
+
version: '3.3'
|
|
106
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
93
|
requirements:
|
|
108
94
|
- - ">="
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
96
|
version: '0'
|
|
111
97
|
requirements: []
|
|
112
|
-
rubygems_version:
|
|
113
|
-
signing_key:
|
|
98
|
+
rubygems_version: 4.0.16
|
|
114
99
|
specification_version: 4
|
|
115
100
|
summary: IceAge
|
|
116
101
|
test_files: []
|