env_test_helpers 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f28fa53386f1e8d0645a14a424b4715243d6aad
4
+ data.tar.gz: f620947b5789fdd1eef0e24d539a210f4752d5ee
5
+ SHA512:
6
+ metadata.gz: fe96b2c0012ad8080d1da7eb64ec5ab09b085d97dc52e0896456055beb362784c3a45a2a7760166c887adfd45a7b0e31bd53005181849599e71642b3acf11f78
7
+ data.tar.gz: 91142560d452cd38112f6663730b7c1bfb2f00bd75e3a7c3e45d32aadbde142a14451db7cdd6102d900ce3a9fbbf2a15dc587cbc93410dc5d639f662c4a0c0e3
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in env_test_helpers.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Artur Pañach
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # EnvTestHelpers
2
+
3
+ Helps to handle env vars in tests.
4
+
5
+ Use case:
6
+ - I have configurations set in ignored files, most of this variables are Api keys or passwords.
7
+ - The code and tests needs this variables but I can not share them in my VCS.
8
+
9
+ Solution:
10
+ - I mock or set this variables in the test they are required.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'env_test_helpers', group: :test
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install env_test_helpers
27
+
28
+ ## Rspec
29
+ All done. _The module gets included in the rspec configure block._
30
+
31
+ ## Else
32
+ ```ruby
33
+ require 'env_test_helpers'
34
+ ```
35
+ or
36
+ ```ruby
37
+ include EnvTestHelpers
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ **Using the variables inside a block:**
43
+ ```ruby
44
+ it 'does something with the FOO environment variable' do
45
+ with_env_vars 'FOO' => 'bar' do
46
+ # logic that depends upon ENV['FOO'] goes here
47
+ end
48
+ end
49
+ ```
50
+
51
+ **As a before block:**
52
+ ```ruby
53
+ describe Thing do
54
+ before(:all) do
55
+ mock_env_vars('FOO' => 'bar')
56
+ end
57
+ it 'does something with the FOO environment variable' do
58
+ # logic that depends upon ENV['FOO'] goes here
59
+ end
60
+ end
61
+ ```
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/[my-github-username]/env_test_helpers/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'env_test_helpers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "env_test_helpers"
8
+ spec.version = EnvTestHelpers::VERSION
9
+ spec.authors = ["Artur Pañach"]
10
+ spec.email = ["arturictus@gmail.com"]
11
+ spec.summary = %q{Helps to handle env vars in tests.}
12
+ spec.description = %q{Use case:
13
+ - I have configurations set in ignored files, most of this variables are Api keys or passwords.
14
+ - The code and tests needs this variables but I can not share them in my VCS.
15
+
16
+ Solution:
17
+ - I mock or set this variables in the test they are required.}
18
+ spec.homepage = "https://github.com/arturictus/env_test_helpers"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0")
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,37 @@
1
+ require "env_test_helpers/version"
2
+
3
+ module EnvTestHelpers
4
+ # it 'does something with the FOO environment variable' do
5
+ # with_env_vars 'FOO' => 'bar' do
6
+ # # logic that depends upon ENV['FOO'] goes here
7
+ # end
8
+ # end
9
+ def with_env_vars(vars)
10
+ original = ENV.to_hash
11
+ vars.each { |k, v| ENV[k] = v }
12
+ begin
13
+ yield
14
+ ensure
15
+ ENV.replace(original)
16
+ end
17
+ end
18
+ # describe Thing do
19
+ # before(:all) do
20
+ # mock_env_vars('FOO' => 'bar')
21
+ # end
22
+ # it 'does something with the FOO environment variable' do
23
+ # # logic that depends upon ENV['FOO'] goes here
24
+ # end
25
+ # end
26
+ def mock_env_vars(vars)
27
+ vars.each do |k, v|
28
+ allow(ENV).to receive(:[]).with(k).and_return(v)
29
+ end
30
+ end
31
+ end
32
+
33
+ if defined? Rspec
34
+ RSpec.configure do |c|
35
+ c.include EnvHelpers
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module EnvTestHelpers
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: env_test_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Artur Pañach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: |-
42
+ Use case:
43
+ - I have configurations set in ignored files, most of this variables are Api keys or passwords.
44
+ - The code and tests needs this variables but I can not share them in my VCS.
45
+
46
+ Solution:
47
+ - I mock or set this variables in the test they are required.
48
+ email:
49
+ - arturictus@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - ".gitignore"
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - env_test_helpers.gemspec
60
+ - lib/env_test_helpers.rb
61
+ - lib/env_test_helpers/version.rb
62
+ homepage: https://github.com/arturictus/env_test_helpers
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Helps to handle env vars in tests.
86
+ test_files: []
87
+ has_rdoc: