fixturama 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 206c66b417306ab1f47517bbbac4fd0bbd3a713fb03a9ab6e01686010c23c9cc
4
- data.tar.gz: 1bc6e5c7f657a7807c724cc5d36cb033da83ee24fc13aa61c01dfcc1d489476e
3
+ metadata.gz: d55872d445c82c193803ee59ad7c09bd5086f7c252025f650b2d63ed2f121720
4
+ data.tar.gz: 1ff0e8705ab7f4d9690fd2750032454fcf22ccfc65dc97314619d5f8299cf92d
5
5
  SHA512:
6
- metadata.gz: 155ac458d289214601ef8162bdc743d875855d094cd783fc79c67a5a0403ece59d4e3a9073245f915e793091be109f7f6f33840cab22c95aee320b88e796efae
7
- data.tar.gz: b8d70001291a4b3f30c076c0ec11d57e5401f9527b384426ae41e9db8e91d025baf0db92bb1101dce63cb94975b781bf279ec11ea0bfc568c0cf7332ccdbe0cc
6
+ metadata.gz: 7c6395d316867b5c9bb05d75cda3238164a0f47a357693086fa21be913ff1c5dff02aa14e7cdf09e3ec350672d6e7c1b063b21aa50a596064298ba4933228377
7
+ data.tar.gz: b6e0f0fadfcd1da51f885376775714ec76a58caa30e84968920c85d1b5618a513646b6a239a4bf61a9d237553861dd2a5223c1a83a9ee6cd79c2c11edf9fa362
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [0.4.0] - [2020-03-15]
9
+
10
+ ### Added
11
+
12
+ - Support for stubbing ENV variables (nepalez)
13
+
14
+ ```yaml
15
+ ---
16
+ - env: GOOGLE_CLOUD_KEY
17
+ value: foo
18
+
19
+ - env: GOOGLE_CLOUD_PASSWORD
20
+ value: bar
21
+ ```
22
+
23
+ This would stub selected variables only, not touching the others
24
+
8
25
  ## [0.3.0] - [2020-03-08]
9
26
 
10
27
  ### Added
@@ -250,3 +267,4 @@ This is a first public release with features extracted from production app.
250
267
  [0.1.0]: https://github.com/nepalez/fixturama/compare/v0.0.7...v0.1.0
251
268
  [0.2.0]: https://github.com/nepalez/fixturama/compare/v0.1.0...v0.2.0
252
269
  [0.3.0]: https://github.com/nepalez/fixturama/compare/v0.2.0...v0.3.0
270
+ [0.4.0]: https://github.com/nepalez/fixturama/compare/v0.3.0...v0.4.0
data/README.md CHANGED
@@ -141,6 +141,11 @@ For constants:
141
141
  - `const` for stubbed constant
142
142
  - `value` for a value of the constant
143
143
 
144
+ For environment variables:
145
+
146
+ - `env` for the name of a variable
147
+ `value` for a value of the variable
148
+
144
149
  For http requests:
145
150
 
146
151
  - `url` or `uri` for the URI of the request (treats values like `/.../` as regular expressions)
@@ -186,9 +191,14 @@ For http requests:
186
191
  arguments:
187
192
  - "Profile with id: 1 not found" # for error message
188
193
 
194
+ # Here we stubbing a constant
189
195
  - const: NOTIFIER_TIMEOUT_SEC
190
196
  value: 10
191
197
 
198
+ # This is a stub for ENV['DEFAULT_EMAIL']
199
+ - env: DEFAULT_EMAIL
200
+ value: foo@example.com
201
+
192
202
  # Examples for stubbing HTTP
193
203
  - uri: /example.com/foo/ # regexp!
194
204
  method: delete
@@ -7,6 +7,7 @@ module Fixturama
7
7
  require_relative "changes/base"
8
8
  require_relative "changes/chain"
9
9
  require_relative "changes/const"
10
+ require_relative "changes/env"
10
11
  require_relative "changes/request"
11
12
  require_relative "changes/seed"
12
13
 
@@ -20,6 +21,7 @@ module Fixturama
20
21
  class: Chain,
21
22
  const: Const,
22
23
  count: Seed,
24
+ env: Env,
23
25
  headers: Request,
24
26
  http_method: Request,
25
27
  object: Chain,
@@ -31,7 +33,6 @@ module Fixturama
31
33
  type: Seed,
32
34
  uri: Request,
33
35
  url: Request,
34
- value: Const,
35
36
  }.freeze
36
37
 
37
38
  # Adds new change to the registry
@@ -0,0 +1,35 @@
1
+ class Fixturama::Changes
2
+ #
3
+ # @private
4
+ # Stub an environment variable
5
+ #
6
+ class Env < Base
7
+ # All changes has the same +key+
8
+ # They will be merged before stubbing (see +call+)
9
+ def key
10
+ "ENV"
11
+ end
12
+
13
+ # When we merge 2 env-s, we just merge their options
14
+ def merge(other)
15
+ return self unless other.is_a?(self.class)
16
+ dup.tap { |env| env.options.update(other.options) }
17
+ end
18
+
19
+ def call(example)
20
+ original = Hash ENV
21
+ example.send(:stub_const, "ENV", original.merge(options))
22
+ self
23
+ end
24
+
25
+ protected
26
+
27
+ attr_reader :options
28
+
29
+ private
30
+
31
+ def initialize(**options)
32
+ @options = { options[:env].to_s => options[:value].to_s }
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,4 @@
1
1
  module Fixturama
2
- VERSION = "0.3.0"
2
+ # The current version of the gem
3
+ VERSION = "0.4.0"
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixturama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin (nepalez)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -131,6 +131,7 @@ files:
131
131
  - lib/fixturama/changes/chain/raise_action.rb
132
132
  - lib/fixturama/changes/chain/return_action.rb
133
133
  - lib/fixturama/changes/const.rb
134
+ - lib/fixturama/changes/env.rb
134
135
  - lib/fixturama/changes/request.rb
135
136
  - lib/fixturama/changes/request/response.rb
136
137
  - lib/fixturama/changes/request/responses.rb