climate_control 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
within a block:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
ClimateControl
|
25
|
+
ClimateControl.modify CONFIRMATION_INSTRUCTIONS_BCC: 'confirmation_bcc@example.com' do
|
26
26
|
sign_up_as 'john@example.com'
|
27
27
|
confirm_account_for_email 'john@example.com'
|
28
28
|
current_email.should bcc_to('confirmation_bcc@example.com')
|
@@ -33,7 +33,7 @@ To use with RSpec, you could define this in your spec:
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
def with_modified_env(options, &block)
|
36
|
-
ClimateControl
|
36
|
+
ClimateControl.modify(options, &block)
|
37
37
|
end
|
38
38
|
```
|
39
39
|
|
@@ -50,7 +50,7 @@ describe Thing, 'name' do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def with_modified_env(options, &block)
|
53
|
-
ClimateControl
|
53
|
+
ClimateControl.modify(options, &block)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
```
|
@@ -63,7 +63,7 @@ describe Thing, 'name' do
|
|
63
63
|
# ... tests
|
64
64
|
|
65
65
|
around do |example|
|
66
|
-
ClimateControl
|
66
|
+
ClimateControl.modify FOO: 'bar' do
|
67
67
|
example.run
|
68
68
|
end
|
69
69
|
end
|
data/lib/climate_control.rb
CHANGED
@@ -5,12 +5,8 @@ module ClimateControl
|
|
5
5
|
def initialize(environment_overrides = {}, &block)
|
6
6
|
@environment_overrides = environment_overrides.dup.stringify_keys!
|
7
7
|
@block = block
|
8
|
-
|
9
|
-
process
|
10
8
|
end
|
11
9
|
|
12
|
-
private
|
13
|
-
|
14
10
|
def process
|
15
11
|
begin
|
16
12
|
prepare_environment_for_block
|
@@ -22,6 +18,8 @@ module ClimateControl
|
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
21
|
+
private
|
22
|
+
|
25
23
|
def prepare_environment_for_block
|
26
24
|
@original_env = clone_environment
|
27
25
|
copy_overrides_to_environment
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Climate control' do
|
4
|
+
it 'allows modification of the environment' do
|
5
|
+
block_run = false
|
6
|
+
ClimateControl.modify FOO: 'bar' do
|
7
|
+
expect(ENV['FOO']).to eq 'bar'
|
8
|
+
block_run = true
|
9
|
+
end
|
10
|
+
|
11
|
+
expect(ENV['FOO']).to be_nil
|
12
|
+
expect(block_run).to be_true
|
13
|
+
end
|
14
|
+
end
|
@@ -58,8 +58,16 @@ describe ClimateControl::Modifier do
|
|
58
58
|
expect(ENV['CHANGED']).to eq 'new value'
|
59
59
|
end
|
60
60
|
|
61
|
+
it 'returns the value of the block' do
|
62
|
+
value = with_modified_env VARIABLE_1: 'bar' do
|
63
|
+
'value inside block'
|
64
|
+
end
|
65
|
+
|
66
|
+
expect(value).to eq 'value inside block'
|
67
|
+
end
|
68
|
+
|
61
69
|
def with_modified_env(options, &block)
|
62
|
-
ClimateControl::Modifier.new(options, &block)
|
70
|
+
ClimateControl::Modifier.new(options, &block).process
|
63
71
|
end
|
64
72
|
|
65
73
|
around do |example|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: climate_control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/climate_control.rb
|
94
94
|
- lib/climate_control/modifier.rb
|
95
95
|
- lib/climate_control/version.rb
|
96
|
+
- spec/acceptance/climate_control_spec.rb
|
96
97
|
- spec/lib/climate_control/modifier_spec.rb
|
97
98
|
- spec/spec_helper.rb
|
98
99
|
homepage: https://github.com/thoughtbot/climate_control
|
@@ -120,6 +121,7 @@ signing_key:
|
|
120
121
|
specification_version: 3
|
121
122
|
summary: Modify your ENV easily with ClimateControl
|
122
123
|
test_files:
|
124
|
+
- spec/acceptance/climate_control_spec.rb
|
123
125
|
- spec/lib/climate_control/modifier_spec.rb
|
124
126
|
- spec/spec_helper.rb
|
125
127
|
has_rdoc:
|