stub_env 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 39c229905b773e1ca5a3e99346059eeef8856091
4
+ data.tar.gz: 0ed7ed295c7c6335b2b535986e81155c548abe61
5
+ SHA512:
6
+ metadata.gz: 9e3e7ab8ae9639600fa02e440b0ebc98fc3eb2b8325d34e0f0227e94075757de5fd2977f73f4cd654c716db77679699f299c90ba3bb5bd74719715d53dab44b2
7
+ data.tar.gz: 3a842b378185c48d3da8c456ab2bd990d17cad4debf76d077666e6cf471fb2f8c99c473d15e88795c22cd47d438045537c8aebdc2abfe0c659eeba8b300292de
data/.git-ignore ADDED
@@ -0,0 +1,2 @@
1
+ .ruby-gemset
2
+ .ruby-version
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ stub_env
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.3
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stub_env (0.0.1)
5
+ rspec (>= 3.0, < 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ rake (10.3.2)
12
+ rspec (3.1.0)
13
+ rspec-core (~> 3.1.0)
14
+ rspec-expectations (~> 3.1.0)
15
+ rspec-mocks (~> 3.1.0)
16
+ rspec-core (3.1.7)
17
+ rspec-support (~> 3.1.0)
18
+ rspec-expectations (3.1.2)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.1.0)
21
+ rspec-mocks (3.1.3)
22
+ rspec-support (~> 3.1.0)
23
+ rspec-support (3.1.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0)
30
+ rake (~> 10.0)
31
+ stub_env!
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright © 2014 LittlOwlLabs
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ Stub Env
2
+ ========
3
+
4
+ This project provides a simple helper method to stub ENV values within RSpec tests.
5
+
6
+ To start using it, install the gem in your project in the test group.
7
+
8
+ ```
9
+ gem 'stub_env'
10
+ ```
11
+
12
+ Then add the following to your rails_config.rb
13
+
14
+ ```
15
+ RSpec.configure do |config|
16
+ config.include StubEnv::Helpers
17
+ end
18
+ ```
19
+
20
+ Then in your examples use:
21
+
22
+ ```
23
+ stub_env('key', 'value')
24
+ ```
25
+
26
+ All ENV values not stubbed will return their original values.
@@ -0,0 +1,10 @@
1
+ module StubEnv
2
+ module Helpers
3
+
4
+ def stub_env key, value
5
+ allow(ENV).to receive(:[]).and_call_original
6
+ allow(ENV).to receive(:[]).with(key).and_return(value)
7
+ end
8
+
9
+ end
10
+ end
data/lib/stub_env.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "stub_env/helpers"
2
+
3
+ module StubEnv
4
+ end
@@ -0,0 +1,5 @@
1
+ require 'stub_env'
2
+
3
+ RSpec.configure do |config|
4
+
5
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe StubEnv::Helpers do
4
+ include described_class
5
+
6
+ describe "#stub_env" do
7
+
8
+ before :each do
9
+ ENV['UNSTUBBED'] = 'unstubbed'
10
+ stub_env('TEST', 'success')
11
+ end
12
+
13
+ it "stubs out environment variables" do
14
+ expect(ENV['TEST']).to eq 'success'
15
+ end
16
+
17
+ it "leaves original environment variables unstubbed" do
18
+ expect(ENV['UNSTUBBED']).to eq 'unstubbed'
19
+ end
20
+ end
21
+ end
data/stub_env.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "stub_env"
5
+ gem.version = "0.1.0"
6
+
7
+ gem.authors = ["Liam Bennett"]
8
+ gem.email = ["liam@littleowllabs.com"]
9
+ gem.summary = "Stub ENV values in RSpec tests"
10
+ gem.description = "RSpec helper for stubbing ENV values"
11
+ gem.homepage = "https://github.com/littleowllabs/stub_env"
12
+ gem.license = "MIT"
13
+
14
+ gem.add_dependency "rspec", ">= 3.0", "< 4.0"
15
+
16
+ gem.add_development_dependency "bundler", "~> 1.0"
17
+ gem.add_development_dependency "rake", "~> 10.0"
18
+
19
+ gem.files = `git ls-files`.split($\)
20
+ gem.test_files = gem.files.grep(/^(spec)/)
21
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stub_env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Liam Bennett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ description: RSpec helper for stubbing ENV values
62
+ email:
63
+ - liam@littleowllabs.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".git-ignore"
69
+ - ".ruby-gemset"
70
+ - ".ruby-version"
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - LICENSE.txt
74
+ - README.md
75
+ - lib/stub_env.rb
76
+ - lib/stub_env/helpers.rb
77
+ - spec/spec_helper.rb
78
+ - spec/stub_env/helpers_spec.rb
79
+ - stub_env.gemspec
80
+ homepage: https://github.com/littleowllabs/stub_env
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Stub ENV values in RSpec tests
104
+ test_files:
105
+ - spec/spec_helper.rb
106
+ - spec/stub_env/helpers_spec.rb