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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2760620f23a7e61b8158f31fa1eb1aa903136ccca5a37c38c079e018cdaeb294
4
- data.tar.gz: c046715ad5d668eef9dab818237c0088da05e6a68ef39ac6c60a41f1f5d991ea
3
+ metadata.gz: 5aef79cd00d3dff9d8ebc088e350e305a24138f1cdc9ac39a5c27e276f5a0f75
4
+ data.tar.gz: 0afc51b74ef066ec4825c54d08638057d714efaa9a8e65417ffc871bba41500c
5
5
  SHA512:
6
- metadata.gz: 49310d47cd6aea17abf6a6edd4553a05ee4fa101d91af64bef0d309e322aa6bed3e205934fa7d293b3f33f2d4222ba6ef9b2447a5b8ada0a2cb0ce54946feaef
7
- data.tar.gz: 606b8cdcb9b612dfcb615ebf58a0f1f4be5d88df910e977a8d98ccdc56ad2d2dc68aae882712c03bcbde73466fbe38a41f82dd5dddb229c6462c92059aaa6b06
6
+ metadata.gz: 7156d83c11ee7544b4a129e96a1dc64822ebc16a54cb056e0f96288c48bd0b892f4b83a40bd8759ee9bbd3680225057392e5185c47b87b4c2265ace4ca7fcb1c
7
+ data.tar.gz: e578cb717cb0a2147b4d1e93b22222e25fe6f597600bacc03b2dc7358dc09e10e472e2d880c7bee5678e6b063cbe287c3653042256167a9ed1f711ee5ef0de4c
@@ -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
- ENV.clear.update(@env)
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 changes
14
- (Set.new(ENV.to_h) - Set.new(@env)).to_h.keys
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
- raise 'ENV changed during test setup: ' + changes.to_s
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
- IceAge.freeze
32
-
33
- if defined? RSpec
36
+ # load framework plugins
37
+ begin
34
38
  require_relative 'ice_age/rspec'
35
- end
39
+ rescue LoadError; end
@@ -0,0 +1,3 @@
1
+ require 'ice_age'
2
+
3
+ IceAge.freeze
@@ -2,7 +2,11 @@ require 'rspec/core'
2
2
 
3
3
  RSpec.configure do |config|
4
4
 
5
- config.before do
5
+ config.before(:suite) do
6
+ IceAge.frozen? ? IceAge.endure! : IceAge.freeze
7
+ end
8
+
9
+ config.after do
6
10
  IceAge.restore
7
11
  end
8
12
 
@@ -0,0 +1,3 @@
1
+ class IceAge
2
+ VERSION = '0.1.3'
3
+ end
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.0.1
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-09-04 00:00:00.000000000 Z
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/core
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
- - spec/ice_age_spec.rb
64
- homepage: https://github.com/dpep/rb_ice_age
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: []
@@ -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