ice_age 0.0.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ice_age.rb +21 -17
- data/lib/ice_age/freeze.rb +3 -0
- data/lib/ice_age/rspec.rb +5 -1
- data/lib/ice_age/version.rb +3 -0
- metadata +35 -7
- data/spec/ice_age_spec.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aef79cd00d3dff9d8ebc088e350e305a24138f1cdc9ac39a5c27e276f5a0f75
|
4
|
+
data.tar.gz: 0afc51b74ef066ec4825c54d08638057d714efaa9a8e65417ffc871bba41500c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7156d83c11ee7544b4a129e96a1dc64822ebc16a54cb056e0f96288c48bd0b892f4b83a40bd8759ee9bbd3680225057392e5185c47b87b4c2265ace4ca7fcb1c
|
7
|
+
data.tar.gz: e578cb717cb0a2147b4d1e93b22222e25fe6f597600bacc03b2dc7358dc09e10e472e2d880c7bee5678e6b063cbe287c3653042256167a9ed1f711ee5ef0de4c
|
data/lib/ice_age.rb
CHANGED
@@ -1,35 +1,39 @@
|
|
1
|
+
require 'ice_age/version'
|
1
2
|
require 'set'
|
2
3
|
|
3
4
|
class IceAge
|
4
|
-
VERSION = '0.0.1'
|
5
|
-
|
6
5
|
class << self
|
7
|
-
def restore
|
8
|
-
raise "#{self.class.name}.frozen never called!" unless @env
|
9
6
|
|
10
|
-
|
7
|
+
def freeze
|
8
|
+
raise 'already frozen' if frozen?
|
9
|
+
|
10
|
+
@env = ENV.to_h.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def frozen?
|
14
|
+
!!@env
|
11
15
|
end
|
12
16
|
|
13
|
-
def
|
14
|
-
|
17
|
+
def restore
|
18
|
+
raise 'not frozen' unless frozen?
|
19
|
+
|
20
|
+
ENV.replace(@env)
|
15
21
|
end
|
16
22
|
|
17
23
|
def endure!
|
24
|
+
raise 'not frozen' unless frozen?
|
25
|
+
|
26
|
+
changes = (Set.new(ENV.to_h) - Set.new(@env)).to_h.keys
|
18
27
|
unless changes.empty?
|
19
|
-
|
28
|
+
msg = changes.map {|k| { k => { @env[k] => ENV[k] } }}.to_s
|
29
|
+
raise 'ENV changed after freeze: ' + msg
|
20
30
|
end
|
21
31
|
end
|
22
32
|
|
23
|
-
def freeze
|
24
|
-
raise 'already frozen' if @env
|
25
|
-
|
26
|
-
@env = ENV.to_h.freeze
|
27
|
-
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
if defined? RSpec
|
36
|
+
# load framework plugins
|
37
|
+
begin
|
34
38
|
require_relative 'ice_age/rspec'
|
35
|
-
end
|
39
|
+
rescue LoadError; end
|
data/lib/ice_age/rspec.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_age
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: codecov
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,21 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - ">="
|
@@ -59,9 +87,10 @@ extensions: []
|
|
59
87
|
extra_rdoc_files: []
|
60
88
|
files:
|
61
89
|
- lib/ice_age.rb
|
90
|
+
- lib/ice_age/freeze.rb
|
62
91
|
- lib/ice_age/rspec.rb
|
63
|
-
-
|
64
|
-
homepage: https://github.com/dpep/
|
92
|
+
- lib/ice_age/version.rb
|
93
|
+
homepage: https://github.com/dpep/ice_age_rb
|
65
94
|
licenses:
|
66
95
|
- MIT
|
67
96
|
metadata: {}
|
@@ -84,5 +113,4 @@ rubygems_version: 3.0.8
|
|
84
113
|
signing_key:
|
85
114
|
specification_version: 4
|
86
115
|
summary: IceAge
|
87
|
-
test_files:
|
88
|
-
- spec/ice_age_spec.rb
|
116
|
+
test_files: []
|
data/spec/ice_age_spec.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# it_behaves_like
|
2
|
-
|
3
|
-
RSpec.shared_examples 'nothing changed' do
|
4
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq '123' }
|
5
|
-
end
|
6
|
-
|
7
|
-
describe IceAge do
|
8
|
-
it_behaves_like 'nothing changed'
|
9
|
-
|
10
|
-
context 'when updated in before block' do
|
11
|
-
before { ENV['ICE_AGE_TEST'] = 'xxx' }
|
12
|
-
|
13
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq 'xxx' }
|
14
|
-
it { expect(ENV.fetch('ICE_AGE_TEST')).to eq 'xxx' }
|
15
|
-
|
16
|
-
context 'when nested' do
|
17
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq 'xxx' }
|
18
|
-
end
|
19
|
-
|
20
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq 'xxx' }
|
21
|
-
|
22
|
-
context 'when nested and changed' do
|
23
|
-
before { ENV['ICE_AGE_TEST'] = 'yyy' }
|
24
|
-
|
25
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq 'yyy' }
|
26
|
-
end
|
27
|
-
|
28
|
-
it { expect(ENV['ICE_AGE_TEST']).to eq 'xxx' }
|
29
|
-
end
|
30
|
-
|
31
|
-
it_behaves_like 'nothing changed'
|
32
|
-
|
33
|
-
|
34
|
-
context 'when updated in an example' do
|
35
|
-
it 'works as expected' do
|
36
|
-
ENV['ICE_AGE_TEST'] = 'zzz'
|
37
|
-
|
38
|
-
expect(ENV['ICE_AGE_TEST']).to eq 'zzz'
|
39
|
-
end
|
40
|
-
|
41
|
-
# then resets
|
42
|
-
it_behaves_like 'nothing changed'
|
43
|
-
end
|
44
|
-
|
45
|
-
it_behaves_like 'nothing changed'
|
46
|
-
|
47
|
-
|
48
|
-
context 'when updated in the wrong spot' do
|
49
|
-
# evaluated before testing starts, when file is initially loaded
|
50
|
-
ENV['ICE_AGE_TEST'] = 'xxx'
|
51
|
-
|
52
|
-
it 'did not permit ENV to change' do
|
53
|
-
expect(ENV['ICE_AGE_TEST']).not_to eq 'xxx'
|
54
|
-
end
|
55
|
-
|
56
|
-
it_behaves_like 'nothing changed'
|
57
|
-
end
|
58
|
-
|
59
|
-
it_behaves_like 'nothing changed'
|
60
|
-
end
|