rspec_in_context 1.1.0.1 → 1.1.0.2
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 +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +5 -1
- data/README.md +2 -1
- data/lib/rspec_in_context/in_context.rb +8 -6
- data/lib/rspec_in_context/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca1a66bd7153a6e92bdce0697bc4d5aa10b50408d5a628cf16faa415827239d
|
4
|
+
data.tar.gz: '0450233344928f09d5e7b1194c46eb07852ab54218591c7073de4ab519268b6e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f61c27dc99d3e451b78d711c9635e4fa864e0409b0037bb409deec8f6613b13d3cd47c5b14a1f42fe357d25fa778efe68e79c5ae9a10b0c1940fd6ba09154ff
|
7
|
+
data.tar.gz: f77fe780d427fd4571d75cdc87ee07f540296792abefefe5ffa1061dffb547a91e73d5cc385734889948a99483cc0f2518371f12c4b2a64f06ab749a1abd546c
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,12 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
## [1.
|
9
|
+
## [1.1.0.1] - 2020-12-27
|
10
10
|
This is a release in order to test all type of actions
|
11
11
|
|
12
12
|
### Added
|
13
13
|
- Cache support in github actions for ease of development
|
14
14
|
|
15
|
+
## [1.1.0.2] - 2021-01-08
|
16
|
+
### Changed
|
17
|
+
- Wrapping silent in_context in anonymous contexts
|
18
|
+
|
15
19
|
## [1.1.0] - 2020-12-27
|
16
20
|
### Added
|
17
21
|
- **BREAKING** Option to silence in_context block. They used to always wrap themself into a context block with their name. This is not the case anymore. All in_context are silent unless explicitely declared as not.
|
data/README.md
CHANGED
@@ -222,8 +222,9 @@ in_context "namespaced context", ns: "namespace name"
|
|
222
222
|
#### Making `in_context` adverstise itself
|
223
223
|
|
224
224
|
The fact that a `in_context` block is used inside the test is silent and invisible by default.
|
225
|
+
`in_context` will still wrap its own execution inside a anonymous context.
|
225
226
|
|
226
|
-
But, there's some case where it helps to make the `in_context` to wrap its execution in a `context` block.
|
227
|
+
But, there's some case where it helps to make the `in_context` to wrap its execution in a named `context` block.
|
227
228
|
For example:
|
228
229
|
```ruby
|
229
230
|
define_context "with my_var defined" do
|
@@ -10,7 +10,7 @@ module RspecInContext
|
|
10
10
|
# @attr [Class] owner current rspec context class. This will be used to know where a define_context has been defined
|
11
11
|
# @attr [String | Symbol] name represent the name by which the context can be find.
|
12
12
|
# @attr [String | Symbol] namespace namespace for context names to avoid collisions
|
13
|
-
# @attr [Boolean] silent does the in_context
|
13
|
+
# @attr [Boolean] silent does the in_context wrap itself into a context with its name or an anonymous context
|
14
14
|
Context = Struct.new(:block, :owner, :name, :namespace, :silent)
|
15
15
|
|
16
16
|
# Main module containing almost every methods
|
@@ -54,7 +54,7 @@ module RspecInContext
|
|
54
54
|
# Look into every namespace to find the context
|
55
55
|
# @api private
|
56
56
|
def find_context_in_any_namespace(context_name)
|
57
|
-
valid_namespace = contexts.find{ |_, namespaced_contexts| namespaced_contexts[context_name] }&.last
|
57
|
+
valid_namespace = contexts.find { |_, namespaced_contexts| namespaced_contexts[context_name] }&.last
|
58
58
|
valid_namespace[context_name] if valid_namespace
|
59
59
|
end
|
60
60
|
|
@@ -62,7 +62,7 @@ module RspecInContext
|
|
62
62
|
# Delete a context
|
63
63
|
def remove_context(current_class)
|
64
64
|
contexts.each_value do |namespaced_contexts|
|
65
|
-
namespaced_contexts.delete_if{ |_, context| context.owner == current_class }
|
65
|
+
namespaced_contexts.delete_if { |_, context| context.owner == current_class }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -87,7 +87,9 @@ module RspecInContext
|
|
87
87
|
Thread.current[:test_block] = block
|
88
88
|
context_to_exec = InContext.find_context(context_name, namespace)
|
89
89
|
if context_to_exec.silent
|
90
|
-
return
|
90
|
+
return context do
|
91
|
+
instance_exec(*args, &context_to_exec.block)
|
92
|
+
end
|
91
93
|
end
|
92
94
|
|
93
95
|
context(context_name.to_s) do
|
@@ -103,7 +105,7 @@ module RspecInContext
|
|
103
105
|
def execute_tests
|
104
106
|
instance_exec(&Thread.current[:test_block]) if Thread.current[:test_block]
|
105
107
|
end
|
106
|
-
|
108
|
+
alias instanciate_context execute_tests
|
107
109
|
|
108
110
|
# Let you define a context that can be reused later
|
109
111
|
#
|
@@ -112,7 +114,7 @@ module RspecInContext
|
|
112
114
|
# It helps reducing colisions when you define "global" contexts
|
113
115
|
# @param ns [String, Symbol] Alias of namespace
|
114
116
|
# @param block [Proc] Contain the code that will be injected with #in_context later
|
115
|
-
# @param silent [Boolean] Does the in_context
|
117
|
+
# @param silent [Boolean] Does the in_context wrap itself into a context with its name or an anonymous context
|
116
118
|
# @param print_context [Boolean] Reverse alias of silent
|
117
119
|
#
|
118
120
|
# @note contexts are scoped to the block they are defined in.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_in_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis <Zaratan> Pasin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|