rspec-stubbed_env 1.0.0 → 1.0.1

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: 0f5215e742c22f09ea48531c86d14314678ccc73d84aa3d854567fe657aaa162
4
- data.tar.gz: 6e060354684b694b98e0f8b5caffdb751044941f9f5f0d03d59903e1c0254623
3
+ metadata.gz: '09e5aa5f7c19b3a1ff91d6b57b675ea43a8df11ea62e166f48b7d75164768d67'
4
+ data.tar.gz: 4c7f81cd1f10be87d1eb1079f4cd48740cee3b8895ba1c776b817d9377bf032f
5
5
  SHA512:
6
- metadata.gz: f0ca35e533aa20855454f485f4623b34904c5287a8c04a5075942e82774ab35bc091fd2190970ba33678ddbd01441f015a0fa7f62879ca11dfdb4c60a33533c0
7
- data.tar.gz: f37af4f2c0e48b87b226e90934f3f1421864f3ed3a48eae46669c9da1e0e33e37d36ae839495bfe082cf42750acebd1713407c8ad1605974338f3d203cec9d50
6
+ metadata.gz: 7c34f17e0d5e8d7adfc1cebfb14d0232377c57dd84464b65ea12d8e71853140ac5d64dc1ab96d50d0ffd53edea9a17e176367c72ae01a4a6d9bb0a9956439402
7
+ data.tar.gz: 4c60b5f7a0a8ad1b09fd07bfc1cab846a6eaa97c8158b39a075dd673e27dbb662ef40b2247853c3931c01e19a886d8271c85934406eab179e52c48ec1d4540e1
checksums.yaml.gz.sig ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog v1](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Added
9
+ ### Changed
10
+ ### Fixed
11
+ ### Removed
12
+
13
+ ## [1.0.1] - 2023-04-01
14
+ ### Added
15
+ - support for values_at (@darhazer)
16
+ - support for symbol keys (@hosamaly)
17
+ - Structured gemfiles
18
+ - Rubocop with standard, gradual, & more
19
+ - Releases are now signed
20
+ - Releases now have checksums
21
+ ### Changed
22
+ - Required ruby version in gemspec >= 1.8.7
23
+ - not bumping major version, because this was already the de-facto minimum
24
+ - TravisCI => GitHub Actions
25
+ - CODE_OF_CONDUCT.md upgraded to v2.0
26
+ - Moved from master to main default branch
27
+ ### Fixed
28
+ - README Badges (CI status)
29
+
30
+ ## [1.0.0] - 2018-10-06
31
+ ### Added
32
+ - negated matchers
33
+ - rubocop config
data/CODE_OF_CONDUCT.md CHANGED
@@ -2,73 +2,83 @@
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
11
8
 
12
9
  ## Our Standards
13
10
 
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
11
+ Examples of behavior that contributes to a positive environment for our community include:
16
12
 
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
22
18
 
23
- Examples of unacceptable behavior by participants include:
19
+ Examples of unacceptable behavior include:
24
20
 
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
28
24
  * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
31
27
  * Other conduct which could reasonably be considered inappropriate in a
32
28
  professional setting
33
29
 
34
- ## Our Responsibilities
30
+ ## Enforcement Responsibilities
35
31
 
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
39
33
 
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
45
35
 
46
36
  ## Scope
47
37
 
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
54
39
 
55
40
  ## Enforcement
56
41
 
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at peter.boling@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
63
59
 
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
67
73
 
68
74
  ## Attribution
69
75
 
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
72
82
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,36 @@
1
+ ## Contributing
2
+
3
+ Bug reports and pull requests are welcome on GitLab at [https://gitlab.com/pboling/rspec-stubbed_env][🚎src-main]
4
+ . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
5
+ the [code of conduct][conduct].
6
+
7
+ To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request
8
+ and post a message to the [gitter chat][🏘chat].
9
+
10
+ ## Release
11
+
12
+ To release a new version:
13
+
14
+ 1. Run `bin/setup && bin/rake` as a tests, coverage, & linting sanity check.
15
+ 2. update the version number in `version.rb`
16
+ 3. run `bundle exec rake build:checksum`
17
+ 4. move the built gem to project root
18
+ 5. run `bin/checksum` to create the missing SHA256 checksum
19
+ 6. move the built gem back to `pkg/`
20
+ 7. commit the changes
21
+ 8. run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org][rubygems].
22
+
23
+ NOTE: You will need to have a public key in `certs/`, and list your cert in the
24
+ `gemspec`, in order to sign the new release.
25
+ See: [RubyGems Security Guide][rubygems-security-guide]
26
+
27
+ ## Contributors
28
+
29
+ See: [https://gitlab.com/pboling/rspec-stubbed_env/-/graphs/main][🖐contributors]
30
+
31
+ [conduct]: https://gitlab.com/pboling/rspec-stubbed_env/-/blob/main/CODE_OF_CONDUCT.md
32
+ [🖐contributors]: https://gitlab.com/pboling/rspec-stubbed_env/-/graphs/main
33
+ [🚎src-main]: https://gitlab.com/pboling/rspec-stubbed_env/-/tree/main
34
+ [🏘chat]: https://matrix.to/#/%23pboling_rspec-stubbed_env:gitter.im
35
+ [rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
36
+ [rubygems]: https://rubygems.org
@@ -1,4 +1,5 @@
1
- Copyright 2018 Peter Boling of railsbling.com
1
+ Copyright © 2014 LittlOwlLabs
2
+ Copyright © 2018-2020, 2023 Peter Boling of railsbling.com
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5
 
data/README.md CHANGED
@@ -1,41 +1,47 @@
1
1
  # RSpec::StubbedEnv
2
2
 
3
- ENV stubbing via a shared context for more powerful tests.
3
+ ENV stubbing via a shared context for more powerful tests. Now you don't need to add dotenv just for your spec suite.
4
4
 
5
5
  ```ruby
6
- describe 'my stubbed test' do
7
- include_context 'with stubbed env'
6
+ describe "my stubbed test" do
7
+ include_context "with stubbed env"
8
8
  before do
9
- stub_env('FOO' => 'is bar')
9
+ stub_env("FOO" => "is bar")
10
10
  end
11
- it 'has a value' do
12
- expect(ENV['FOO']).to eq('is bar')
11
+ it "has a value" do
12
+ expect(ENV.fetch("FOO", nil)).to(eq("is bar"))
13
13
  end
14
14
  end
15
15
  ```
16
16
 
17
- | Project | RSpec::StubbedEnv |
18
- |------------------------ | ----------------------- |
19
- | gem name | [rspec-stubbed_env](https://rubygems.org/gems/rspec-stubbed_env) |
20
- | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
21
- | download rank | [![Downloads Today](https://img.shields.io/gem/rd/rspec-stubbed_env.svg)](https://github.com/pboling/rspec-stubbed_env) |
22
- | version | [![Version](https://img.shields.io/gem/v/rspec-stubbed_env.svg)](https://rubygems.org/gems/rspec-stubbed_env) |
23
- | continuous integration | [![Build Status](https://travis-ci.org/pboling/rspec-stubbed_env.svg?branch=master)](https://travis-ci.org/pboling/rspec-stubbed_env) |
24
- | test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/07a1d53634c61154efae/test_coverage)](https://codeclimate.com/github/pboling/rspec-stubbed_env/test_coverage) |
25
- | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/07a1d53634c61154efae/maintainability)](https://codeclimate.com/github/pboling/rspec-stubbed_env/maintainability) |
26
- | dependencies | [![Depfu](https://badges.depfu.com/badges/a48948dd503f23a440f2c17910563f43/count.svg)](https://depfu.com/github/pboling/rspec-stubbed_env?project_id=5884) |
27
- | code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/rspec-stubbed_env/badges/users.svg)](https://www.codetriage.com/pboling/rspec-stubbed_env) |
28
- | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
29
- | documentation | [on RDoc.info][documentation] |
30
- | Spread ~♡ⓛⓞⓥⓔ♡~ | [🌍 🌎 🌏](https://about.me/peter.boling), [🍚](https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling), [](https://plus.google.com/+PeterBoling/posts), [👼](https://angel.co/peter-boling), [🐛](https://www.topcoder.com/members/pboling/), [:shipit:](http://coderwall.com/pboling), [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)](http://twitter.com/galtzo) |
31
-
17
+ | Project | RSpec::StubbedEnv |
18
+ |------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
19
+ | gem name | [rspec-stubbed_env](https://rubygems.org/gems/rspec-stubbed_env) |
20
+ | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
21
+ | download rank | [![Downloads Today](https://img.shields.io/gem/rd/rspec-stubbed_env.svg)](https://github.com/pboling/rspec-stubbed_env) |
22
+ | version | [![Version](https://img.shields.io/gem/v/rspec-stubbed_env.svg)](https://rubygems.org/gems/rspec-stubbed_env) |
23
+ | dependencies | [![Depfu][depfu-img]][depfu] |
24
+ | continuous integration | [![Current][🚎cwfi]][🚎cwf] [![Heads][🖐hwfi]][🖐hwf] [![Style][🧮swfi]][🧮swf] |
25
+ | test coverage | [![Test Coverage][cc-covi]][cc-cov] |
26
+ | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/07a1d53634c61154efae/maintainability)](https://codeclimate.com/github/pboling/rspec-stubbed_env/maintainability) |
27
+ | code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/rspec-stubbed_env/badges/users.svg)](https://www.codetriage.com/pboling/rspec-stubbed_env) |
28
+ | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
29
+ | documentation | [on RDoc.info][documentation] |
30
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay], [🧊][🧊berg], [🛖][🛖hut], [🧪][🧪lab], [🌏][aboutme], [👼][angellist], [⚗️][devto], [![Tweet @galtzo][followme]][twitter] |
31
+
32
+ [🚎cwf]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/current.yml
33
+ [🚎cwfi]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/current.yml/badge.svg
34
+ [🖐hwf]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/heads.yml
35
+ [🖐hwfi]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/heads.yml/badge.svg
36
+ [🧮swf]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/style.yml
37
+ [🧮swfi]: https://github.com/pboling/rspec-stubbed_env/actions/workflows/style.yml/badge.svg
32
38
 
33
39
  ## Installation
34
40
 
35
41
  Add this line to your application's Gemfile:
36
42
 
37
43
  ```ruby
38
- gem 'rspec-stubbed_env', group: :test
44
+ gem "rspec-stubbed_env", :group => :test
39
45
  ```
40
46
 
41
47
  And then execute:
@@ -51,16 +57,21 @@ You must configure RSpec to use the `:expect` syntax, or some compatible alterna
51
57
 
52
58
  ```ruby
53
59
  RSpec.configure do |config|
54
- config.expect_with :rspec do |c|
60
+ config.expect_with(:rspec) do |c|
55
61
  c.syntax = :expect
56
62
  end
57
63
  end
58
64
  ```
59
65
 
66
+ Require the library in your spec/test helper somewhere:
67
+ ```
68
+ require "rspec/stubbed_env"
69
+ ```
70
+
60
71
  ## Usage
61
72
 
62
73
  ENV stubbing:
63
-
74
+
64
75
  - is opt-in, via a shared context, rather than global.
65
76
  - *does not* affect the real ENV at all. It is a true stub.
66
77
  - has the same scope as a `before`, `subject`, or `let` at the same level.
@@ -69,37 +80,53 @@ See the spec suite for detailed examples.
69
80
 
70
81
  ```ruby
71
82
  # This is normal, without stubbing, ENV is not set
72
- describe 'vanilla' do
73
- it 'has no ENV stub' do
74
- expect(ENV['FOO']).to be_nil
83
+ describe "vanilla" do
84
+ it "has no ENV stub" do
85
+ expect(ENV.fetch("FOO", nil)).to(be_nil)
75
86
  end
76
87
  end
77
88
 
78
89
  # With a stubbed ENV!
79
- describe 'my stubbed test' do
80
- include_context 'with stubbed env'
90
+ describe "my stubbed test" do
91
+ include_context "with stubbed env"
81
92
  before do
82
- stub_env('FOO' => 'is bar')
93
+ stub_env("FOO" => "is bar")
83
94
  end
84
- it 'has a value' do
85
- expect(ENV['FOO']).to eq('is bar')
95
+ it "has a value" do
96
+ expect(ENV.fetch("FOO", nil)).to(eq("is bar"))
86
97
  end
87
98
  end
88
99
  ```
89
100
 
101
+ ## Switcch to `main` branch
102
+
103
+ We recently migrated from `master` to `main` as the default branch. If this affected your local checkout:
104
+ ```shell
105
+ git branch -m master main
106
+ git fetch origin
107
+ git branch -u origin/main main
108
+ git remote set-head origin -a
109
+ ```
110
+
90
111
  ## Development
91
112
 
92
113
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
114
 
94
115
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
116
 
117
+ ## Authors
118
+
119
+ * [Liam Bennet](https://github.com/ljkbennett) of LittleOwlLabs was the original author.
120
+ * [Peter H. Boling][peterboling] of [Rails Bling][railsbling] is has been maintaining since 2018.
121
+
96
122
  ## Contributing
97
123
 
98
- Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/rspec-stubbed_env.
124
+ See [CONTRIBUTING.md][contributing].
125
+ [contributing]: https://gitlab.com/pboling/rspec-stubbed_env/-/blob/main/CONTRIBUTING.md
99
126
 
100
127
  ## Code of Conduct
101
128
 
102
- Everyone interacting in the AnonymousActiveRecord project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/rspec-stubbed_env/blob/master/CODE_OF_CONDUCT.md).
129
+ Everyone interacting in the AnonymousActiveRecord project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][conduct].
103
130
 
104
131
  ## Versioning
105
132
 
@@ -113,23 +140,42 @@ only be introduced with new major versions.
113
140
  As a result of this policy, you can (and should) specify a
114
141
  dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
115
142
 
116
- For example:
143
+ For example in a `Gemfile`:
117
144
 
118
- ```ruby
119
- spec.add_dependency 'rspec-stubbed_env', '~> 1.0'
120
- ```
145
+ gem 'rspec-stubbed_env', '~> 1.0', group: [:development, :test]
146
+
147
+ or in a `gemspec`
148
+
149
+ spec.add_development_dependency 'rspec-stubbed_env', '~> 1.0'
121
150
 
122
151
  ## License
123
152
 
124
- * Copyright (c) 2018 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
153
+ * Copyright © 2014 LittlOwlLabs [Liam Bennet](https://github.com/ljkbennett)
154
+ * Copyright © 2018-2020, 2023 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
125
155
 
126
156
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
127
157
 
128
- [license]: LICENSE
129
- [semver]: http://semver.org/
130
- [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
131
- [railsbling]: http://www.railsbling.com
132
- [peterboling]: http://www.peterboling.com
158
+ [aboutme]: https://about.me/peter.boling
159
+ [angellist]: https://angel.co/peter-boling
160
+ [blogpage]: http://www.railsbling.com/tags/rspec-stubbed_env/
161
+ [cc-cov]: https://codeclimate.com/github/pboling/rspec-stubbed_env/test_coverage
162
+ [cc-covi]: https://api.codeclimate.com/v1/badges/07a1d53634c61154efae/test_coverage
163
+ [conduct]: CODE_OF_CONDUCT.md
164
+ [contributing]: CONTRIBUTING.md
165
+ [depfu]: https://depfu.com/github/pboling/rspec-stubbed_env?project_id=5884
166
+ [depfu-img]: https://badges.depfu.com/badges/a48948dd503f23a440f2c17910563f43/count.svg
167
+ [devto]: https://dev.to/galtzo
133
168
  [documentation]: http://rdoc.info/github/pboling/rspec-stubbed_env/frames
169
+ [followme]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
134
170
  [homepage]: https://github.com/pboling/rspec-stubbed_env/
135
- [blogpage]: http://www.railsbling.com/tags/rspec-stubbed_env/
171
+ [license]: LICENSE.txt
172
+ [peterboling]: http://www.peterboling.com
173
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
174
+ [railsbling]: http://www.railsbling.com
175
+ [semver]: http://semver.org/
176
+ [twitter]: http://twitter.com/galtzo
177
+ [🧊berg]: https://codeberg.org/pboling
178
+ [🛖hut]: https://sr.ht/~galtzo/
179
+ [🧪lab]: https://gitlab.com/pboling
180
+ [⛳liberapay]: https://liberapay.com/pboling/donate
181
+ [⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay
@@ -16,6 +16,6 @@
16
16
  # end
17
17
  #
18
18
 
19
- RSpec.shared_context 'with stubbed env' do
19
+ RSpec.shared_context("with stubbed env") do
20
20
  include RSpec::StubbedEnv::TestHelpers
21
21
  end
@@ -9,12 +9,21 @@
9
9
  # include_context 'with stubbed env'
10
10
  # before do
11
11
  # stub_env('FOO' => 'is bar')
12
+ # # or, equivalently:
13
+ # stub_env(FOO: 'is bar')
14
+ # # or, equivalently:
15
+ # stub_env('FOO', 'is bar')
16
+ # # or, equivalently:
17
+ # stub_env(FOO: 'is bar')
12
18
  # end
13
19
  # it 'does a thing' do
14
20
  # expect(ENV['FOO']).to eq('is bar')
15
21
  # end
16
22
  # end
17
23
  #
24
+ # NOTE: This file was originally written by Liam Bennet (https://github.com/ljkbennett)
25
+ # as part of the stub_env library (https://github.com/ljkbennett/stub_env).
26
+ # It has evolved since then.
18
27
  module RSpec
19
28
  module StubbedEnv
20
29
  # Helpers to unobtrusively stub ENV
@@ -30,32 +39,50 @@ module RSpec
30
39
  # stub_env('E', 'F')
31
40
  def stub_env(key_or_hash, value = nil)
32
41
  init_stub unless env_stubbed?
33
- if key_or_hash.is_a? Hash
42
+ if key_or_hash.is_a?(Hash)
34
43
  key_or_hash.each { |k, v| add_stubbed_value(k, v) }
35
44
  else
36
- add_stubbed_value key_or_hash, value
45
+ add_stubbed_value(key_or_hash, value)
37
46
  end
38
47
  end
39
48
 
40
49
  private
41
50
 
42
- STUBBED_KEY = '__STUBBED__'
51
+ STUBBED_KEY = "__STUBBED__"
43
52
 
44
53
  def add_stubbed_value(key, value)
45
- allow(ENV).to receive(:[]).with(key).and_return(value)
46
- allow(ENV).to receive(:fetch).with(key).and_return(value)
47
- allow(ENV).to receive(:fetch).with(key, anything) do |_, default_val|
54
+ key = key.to_s # Support symbols by forcing to string
55
+ allow_brackets(key, value)
56
+ allow_fetch(key, value)
57
+ allow_values_at
58
+ end
59
+
60
+ def allow_brackets(key, value)
61
+ allow(ENV).to(receive(:[]).with(key).and_return(value))
62
+ end
63
+
64
+ def allow_fetch(key, value)
65
+ allow(ENV).to(receive(:fetch).with(key).and_return(value))
66
+ allow(ENV).to(receive(:fetch).with(key, anything)) do |_, default_val|
48
67
  value || default_val
49
68
  end
50
69
  end
51
70
 
71
+ # Rides on the fetch stub!
72
+ def allow_values_at
73
+ allow(ENV).to(receive(:values_at)) do |*args|
74
+ args.map { |arg| ENV.fetch(arg, nil) }
75
+ end
76
+ end
77
+
52
78
  def env_stubbed?
53
- ENV[STUBBED_KEY]
79
+ ENV.fetch(STUBBED_KEY, nil)
54
80
  end
55
81
 
56
82
  def init_stub
57
- allow(ENV).to receive(:[]).and_call_original
58
- allow(ENV).to receive(:fetch).and_call_original
83
+ allow(ENV).to(receive(:[]).and_call_original)
84
+ allow(ENV).to(receive(:fetch).and_call_original)
85
+ allow(ENV).to(receive(:values_at).and_call_original)
59
86
  add_stubbed_value(STUBBED_KEY, true)
60
87
  end
61
88
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module StubbedEnv
5
- VERSION = '1.0.0'
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec/stubbed_env/version'
4
-
5
- # External Gems
6
- require 'rspec'
3
+ require "rspec/stubbed_env/version"
7
4
 
8
5
  # This Gem
9
- require 'rspec/stubbed_env/test_helpers'
10
- require 'rspec/stubbed_env/config'
6
+ require "rspec/stubbed_env/test_helpers"
7
+ require "rspec/stubbed_env/config"
11
8
 
12
9
  #
13
10
  # ENV stubbing is opt-in, via a shared context, rather than global
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,71 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-stubbed_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
+ - Liam Bennett
7
8
  - Peter Boling
8
- autorequire:
9
+ autorequire:
9
10
  bindir: exe
10
- cert_chain: []
11
- date: 2018-10-06 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
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.16'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.16'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '12.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '12.3'
55
- - !ruby/object:Gem::Dependency
56
- name: simplecov
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.16'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.16'
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl
15
+ ci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
16
+ A2NvbTAeFw0yMjA5MTgyMzEyMzBaFw0yMzA5MTgyMzEyMzBaMEMxFTATBgNVBAMM
17
+ DHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
18
+ LGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA2Dn1GM3W
19
+ 8K2/rvN1zz+06bQMcxD16ZKTihVwi7Pb1v3T98rM4Omnxohm3s+CwpDWGeiB9pj6
20
+ 0I/CTce0e4e3s8GKJSOrg93veImPSoH2PfsMsRsuB8wtqyiOCjLbF5o6S29x87r0
21
+ LA5EawH+Lh4xqrkkPjdffsmLk7TaCig/vlmNvnzxXKBdey/X/aEJZXzzBiWRfVdh
22
+ O1fmMbVKyieGv9HK7+pLotIoT08bjDv8NP6V7zZslwQRqW27bQc6cqC2LGIbTYO3
23
+ 3jt1kQxfMWmhOictS6SzG9VtKSrXf0L4Neq0Gh7CLBZBvJFWJYZPfb92YNITDbd8
24
+ emPOAQlXXNMN4mMXsEqtEhCPZRMnmwO+fOk/cC4AyglKi9lnQugCQoFV1XDMZST/
25
+ CYbzdQyadOdPDInTntG6V+Uw51d2QGXZ6PDDfrx9+toc/3sl5h68rCUGgE6Q3jPz
26
+ srinqmBsxv2vTpmd4FjmiAtEnwH5/ooLpQYL8UdAjEoeysxS3AwIh+5dAgMBAAGj
27
+ fzB9MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQWU6D156a2cle+
28
+ lb5RBfvVXlxTwjAhBgNVHREEGjAYgRZwZXRlci5ib2xpbmdAZ21haWwuY29tMCEG
29
+ A1UdEgQaMBiBFnBldGVyLmJvbGluZ0BnbWFpbC5jb20wDQYJKoZIhvcNAQELBQAD
30
+ ggGBAJ4SqhPlgUiLYIrphGXIaxXScHyvx4kixuvdrwhI4VoQV2qXvO7R6ZjOXVwX
31
+ f/z84BWPiTZ8lzThPbt1UV/BGwkvLw9I4RjOdzvUz3J42j9Ly6q63isall07bo3F
32
+ QWe/OBvIMBF1IbjC3q5vKPg4rq8+TkNRJNoE86U2gfR+PkW3jYYs9uiy0GloHDCP
33
+ k5xgaj0vSL0Uy5mTOPdk3K6a/sUGZyYniWK05zdhIi956ynhfGaFO988FFdVw5Jq
34
+ LHtXfIpAU8F7ES04syZSslxOluw7VlcSKyRdVIr737J92ZTduppB4PRGSKRgBsWV
35
+ hXTahRE72Kyw53Q7FAuzF3v102WxAAQ7BuMjW+MyCUT75fwPm3W4ELPL8HYkNGE7
36
+ 2oA5CPghFitRnvYS3GNrDG+9bNiRMEskeaBYwZ9UgReBQIwGYVj7LZk3UhiAsn44
37
+ gwGrEXGQGDZ0NIgBcmvMOqlXjkGQwQvugKycJ024z89+fz2332vdZIKTrSxJrXGk
38
+ 4/bR9A==
39
+ -----END CERTIFICATE-----
40
+ date: 2023-04-01 00:00:00.000000000 Z
41
+ dependencies: []
69
42
  description: |-
70
43
  Stub environment variables in a scoped context for testing
71
44
  stub_env(
@@ -78,28 +51,28 @@ executables: []
78
51
  extensions: []
79
52
  extra_rdoc_files: []
80
53
  files:
81
- - ".gitignore"
82
- - ".pryrc"
83
- - ".rspec"
84
- - ".ruby-version"
85
- - ".travis.yml"
54
+ - CHANGELOG.md
86
55
  - CODE_OF_CONDUCT.md
87
- - Gemfile
88
- - LICENSE
56
+ - CONTRIBUTING.md
57
+ - LICENSE.txt
89
58
  - README.md
90
- - Rakefile
91
- - bin/console
92
- - bin/setup
93
59
  - lib/rspec/stubbed_env.rb
94
60
  - lib/rspec/stubbed_env/config.rb
95
61
  - lib/rspec/stubbed_env/test_helpers.rb
96
62
  - lib/rspec/stubbed_env/version.rb
97
- - rspec-stubbed_env.gemspec
98
63
  homepage: https://github.com/pboling/rspec-stubbed_env
99
64
  licenses:
100
65
  - MIT
101
- metadata: {}
102
- post_install_message:
66
+ metadata:
67
+ homepage_uri: https://github.com/pboling/rspec-stubbed_env
68
+ source_code_uri: https://github.com/pboling/rspec-stubbed_env/tree/v1.0.1
69
+ changelog_uri: https://github.com/pboling/rspec-stubbed_env/blob/v1.0.1/CHANGELOG.md
70
+ bug_tracker_uri: https://github.com/pboling/rspec-stubbed_env/issues
71
+ documentation_uri: https://www.rubydoc.info/gems/rspec-stubbed_env/1.0.1
72
+ funding_uri: https://liberapay.com/pboling
73
+ wiki_uri: https://github.com/pboling/rspec-stubbed_env/wiki
74
+ rubygems_mfa_required: 'true'
75
+ post_install_message:
103
76
  rdoc_options: []
104
77
  require_paths:
105
78
  - lib
@@ -107,16 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
80
  requirements:
108
81
  - - ">="
109
82
  - !ruby/object:Gem::Version
110
- version: '0'
83
+ version: 1.8.7
111
84
  required_rubygems_version: !ruby/object:Gem::Requirement
112
85
  requirements:
113
86
  - - ">="
114
87
  - !ruby/object:Gem::Version
115
88
  version: '0'
116
89
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.7.7
119
- signing_key:
90
+ rubygems_version: 3.4.10
91
+ signing_key:
120
92
  specification_version: 4
121
93
  summary: Unobtrusively stub ENV keys and values during testing
122
94
  test_files: []
metadata.gz.sig ADDED
Binary file
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- .byebug_history
14
-
15
- # iCloud Drive
16
- .nosync
17
-
18
- *.gem
19
- /Gemfile.lock
data/.pryrc DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if defined?(PryByebug)
4
- Pry.commands.alias_command 'c', 'continue'
5
- Pry.commands.alias_command 's', 'step'
6
- Pry.commands.alias_command 'n', 'next'
7
- Pry.commands.alias_command 'trace', 'backtrace'
8
- end
9
-
10
- # Hit Enter to repeat last command
11
- Pry::Commands.command /^$/, 'repeat last command' do
12
- _pry_.run_command Pry.history.to_a.last
13
- end
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.5.1
data/.travis.yml DELETED
@@ -1,32 +0,0 @@
1
- ---
2
- env:
3
- global:
4
- - JRUBY_OPTS="-Xcli.debug=true --debug"
5
- - CC_TEST_REPORTER_ID=3ed1c79841ccc5d053b995c63c0ead562427a77dba728601b8d19f02b16ac0f2
6
-
7
- before_script:
8
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
- - chmod +x ./cc-test-reporter
10
- - ./cc-test-reporter before-build
11
-
12
- script:
13
- - bundle exec rake
14
-
15
- after_script:
16
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
17
-
18
- before_install:
19
- - gem update --system
20
- - gem install bundler -v 1.16.5
21
-
22
- install:
23
- - bundle install
24
-
25
- bundler_args: --no-deployment --jobs 3 --retry 3
26
-
27
- language: ruby
28
- cache: bundler
29
- rvm:
30
- - 2.3.7
31
- - 2.4.4
32
- - 2.5.1
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in rspec-stubbed_env.gemspec
8
- gemspec
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'rspec/stubbed_env'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'rspec/stubbed_env/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'rspec-stubbed_env'
9
- spec.version = RSpec::StubbedEnv::VERSION
10
- spec.authors = ['Peter Boling']
11
- spec.email = ['peter.boling@gmail.com']
12
-
13
- spec.summary = 'Unobtrusively stub ENV keys and values during testing'
14
- spec.description = %[Stub environment variables in a scoped context for testing
15
- stub_env(
16
- 'AWS_REGION' => 'us-east-1',
17
- 'REDIS_URL' => 'redis://localhost:6379/'
18
- )]
19
- spec.homepage = 'https://github.com/pboling/rspec-stubbed_env'
20
- spec.license = 'MIT'
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- end
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
30
-
31
- spec.add_runtime_dependency 'rspec', '>= 3.0'
32
-
33
- spec.add_development_dependency 'bundler', '~> 1.16'
34
- spec.add_development_dependency 'rake', '~> 12.3'
35
- spec.add_development_dependency 'simplecov', '~> 0.16'
36
- end