rspec_in_context 1.1.0.3 → 1.2.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 +4 -4
- data/.github/workflows/test_and_publish.yml +15 -10
- data/.github/workflows/test_only.yml +12 -7
- data/.github/workflows/verify_version_change.yml +6 -2
- data/.gitignore +7 -0
- data/.rubocop-remote-fc7fff8f41d19bde0dcc446ded612e75.yml +153 -0
- data/.rubocop.yml +12 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +36 -1
- data/LLMS.md +388 -0
- data/README.md +237 -73
- data/TODO.md +44 -0
- data/examples/README.md +23 -0
- data/examples/contexts/active_job_context.rb +15 -0
- data/examples/contexts/authenticated_request_context.rb +27 -0
- data/examples/contexts/composed_context.rb +13 -0
- data/examples/contexts/frozen_time_context.rb +8 -0
- data/examples/contexts/inline_mailer_context.rb +15 -0
- data/examples/contexts/interactor_contract_context.rb +23 -0
- data/examples/usage/composed_context_spec.rb +15 -0
- data/examples/usage/interactor_spec.rb +23 -0
- data/examples/usage/nested_contexts_spec.rb +30 -0
- data/examples/usage/request_spec.rb +29 -0
- data/lib/rspec_in_context/context_management.rb +1 -3
- data/lib/rspec_in_context/in_context.rb +137 -35
- data/lib/rspec_in_context/version.rb +1 -3
- data/lib/rspec_in_context.rb +13 -9
- data/package.json +16 -2
- data/rspec_in_context.gemspec +21 -20
- data/yarn.lock +8 -10
- metadata +28 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e63cf4bd9f911ee7f0434682e2b104578555086eba35590ff0c8d72214ef2f48
|
|
4
|
+
data.tar.gz: d4737b49923e3a8080603987f4c490d19ed798f824ce0822dd0e349028683c79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 589321b198f19691378d28b67aa92beb237ba1bf6ceca7f78fc6fee08ad983cf94467ce4b288007ae98e825ab57aaa441c872ee3a0234d674b88e7e733d2a762
|
|
7
|
+
data.tar.gz: fac8b3dd1d6bb726f51fdd3377fcdf10092129d0e005bbd3133ff7169bd6dcf4a22fdedb97dc77602890b489014e2105e76b82c0a8480316d00250802a4b026f
|
|
@@ -2,18 +2,18 @@ name: Test and Release
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches:
|
|
5
|
+
branches:
|
|
6
6
|
- main
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
tests:
|
|
10
10
|
strategy:
|
|
11
11
|
matrix:
|
|
12
|
-
ruby: [2
|
|
12
|
+
ruby: ['3.2', '3.3', '3.4', '4.0']
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
17
|
- name: Set up Ruby
|
|
18
18
|
uses: ruby/setup-ruby@v1
|
|
19
19
|
with:
|
|
@@ -26,25 +26,30 @@ jobs:
|
|
|
26
26
|
prettier:
|
|
27
27
|
runs-on: ubuntu-latest
|
|
28
28
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- name: Set up Ruby
|
|
31
|
+
uses: ruby/setup-ruby@v1
|
|
32
|
+
with:
|
|
33
|
+
ruby-version: '3.4'
|
|
34
|
+
bundler-cache: true
|
|
30
35
|
- name: Set up Node
|
|
31
|
-
uses: actions/setup-node@
|
|
36
|
+
uses: actions/setup-node@v4
|
|
32
37
|
with:
|
|
33
|
-
node-version: '
|
|
38
|
+
node-version: '22'
|
|
34
39
|
- name: Install yarn dep
|
|
35
40
|
run: yarn install
|
|
36
41
|
- name: Check prettier
|
|
37
|
-
run: yarn prettier -c '
|
|
42
|
+
run: yarn prettier -c 'lib/**/*.rb' 'spec/**/*.rb' '*.gemspec' Gemfile
|
|
38
43
|
release:
|
|
39
44
|
needs: [tests, prettier]
|
|
40
45
|
runs-on: ubuntu-latest
|
|
41
46
|
|
|
42
47
|
steps:
|
|
43
|
-
- uses: actions/checkout@
|
|
48
|
+
- uses: actions/checkout@v4
|
|
44
49
|
- name: Set up Ruby
|
|
45
50
|
uses: ruby/setup-ruby@v1
|
|
46
51
|
with:
|
|
47
|
-
ruby-version: 3.
|
|
52
|
+
ruby-version: '3.4'
|
|
48
53
|
bundler-cache: true
|
|
49
54
|
- name: Prepare credentials
|
|
50
55
|
env:
|
|
@@ -55,4 +60,4 @@ jobs:
|
|
|
55
60
|
- name: Fetch tags from remote
|
|
56
61
|
run: "git fetch -t"
|
|
57
62
|
- name: Publish if version change
|
|
58
|
-
run: 'git diff
|
|
63
|
+
run: 'git diff $(git tag --sort=-v:refname | head -1) -- lib/rspec_in_context/version.rb | grep -E "^\+.*VERSION" && rake release || echo "No release for now"'
|
|
@@ -2,18 +2,18 @@ name: Tests
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches-ignore:
|
|
5
|
+
branches-ignore:
|
|
6
6
|
- main
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
tests:
|
|
10
10
|
strategy:
|
|
11
11
|
matrix:
|
|
12
|
-
ruby: [2
|
|
12
|
+
ruby: ['3.2', '3.3', '3.4', '4.0']
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
17
|
- name: Set up Ruby
|
|
18
18
|
uses: ruby/setup-ruby@v1
|
|
19
19
|
with:
|
|
@@ -26,12 +26,17 @@ jobs:
|
|
|
26
26
|
prettier:
|
|
27
27
|
runs-on: ubuntu-latest
|
|
28
28
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- name: Set up Ruby
|
|
31
|
+
uses: ruby/setup-ruby@v1
|
|
32
|
+
with:
|
|
33
|
+
ruby-version: '3.4'
|
|
34
|
+
bundler-cache: true
|
|
30
35
|
- name: Set up Node
|
|
31
|
-
uses: actions/setup-node@
|
|
36
|
+
uses: actions/setup-node@v4
|
|
32
37
|
with:
|
|
33
|
-
node-version: '
|
|
38
|
+
node-version: '22'
|
|
34
39
|
- name: Install yarn dep
|
|
35
40
|
run: yarn install
|
|
36
41
|
- name: Check prettier
|
|
37
|
-
run: yarn prettier -c '
|
|
42
|
+
run: yarn prettier -c 'lib/**/*.rb' 'spec/**/*.rb' '*.gemspec' Gemfile
|
|
@@ -10,7 +10,7 @@ jobs:
|
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
14
|
- name: Fetch main branch
|
|
15
15
|
run: git fetch origin main:main
|
|
16
16
|
- name: Verify if there's a change in version
|
|
@@ -18,4 +18,8 @@ jobs:
|
|
|
18
18
|
- name: Print new version
|
|
19
19
|
run: 'git diff main -- lib/rspec_in_context/version.rb | grep -E "^\+.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?"'
|
|
20
20
|
- name: Verify if higher version
|
|
21
|
-
run:
|
|
21
|
+
run: |
|
|
22
|
+
NEW_VERSION=$(git diff main -- lib/rspec_in_context/version.rb | grep -E "^\+.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?")
|
|
23
|
+
OLD_VERSION=$(git diff main -- lib/rspec_in_context/version.rb | grep -E "^-.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?")
|
|
24
|
+
HIGHEST=$(echo -e "$OLD_VERSION\n$NEW_VERSION" | sort -V | tail -1)
|
|
25
|
+
[[ "$HIGHEST" == "$NEW_VERSION" && "$OLD_VERSION" != "$NEW_VERSION" ]]
|
data/.gitignore
CHANGED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Relaxed.Ruby.Style
|
|
2
|
+
## Version 2.5
|
|
3
|
+
|
|
4
|
+
Style/Alias:
|
|
5
|
+
Enabled: false
|
|
6
|
+
StyleGuide: https://relaxed.ruby.style/#stylealias
|
|
7
|
+
|
|
8
|
+
Style/AsciiComments:
|
|
9
|
+
Enabled: false
|
|
10
|
+
StyleGuide: https://relaxed.ruby.style/#styleasciicomments
|
|
11
|
+
|
|
12
|
+
Style/BeginBlock:
|
|
13
|
+
Enabled: false
|
|
14
|
+
StyleGuide: https://relaxed.ruby.style/#stylebeginblock
|
|
15
|
+
|
|
16
|
+
Style/BlockDelimiters:
|
|
17
|
+
Enabled: false
|
|
18
|
+
StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
|
|
19
|
+
|
|
20
|
+
Style/CommentAnnotation:
|
|
21
|
+
Enabled: false
|
|
22
|
+
StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
|
|
23
|
+
|
|
24
|
+
Style/Documentation:
|
|
25
|
+
Enabled: false
|
|
26
|
+
StyleGuide: https://relaxed.ruby.style/#styledocumentation
|
|
27
|
+
|
|
28
|
+
Layout/DotPosition:
|
|
29
|
+
Enabled: false
|
|
30
|
+
StyleGuide: https://relaxed.ruby.style/#layoutdotposition
|
|
31
|
+
|
|
32
|
+
Style/DoubleNegation:
|
|
33
|
+
Enabled: false
|
|
34
|
+
StyleGuide: https://relaxed.ruby.style/#styledoublenegation
|
|
35
|
+
|
|
36
|
+
Style/EndBlock:
|
|
37
|
+
Enabled: false
|
|
38
|
+
StyleGuide: https://relaxed.ruby.style/#styleendblock
|
|
39
|
+
|
|
40
|
+
Style/FormatString:
|
|
41
|
+
Enabled: false
|
|
42
|
+
StyleGuide: https://relaxed.ruby.style/#styleformatstring
|
|
43
|
+
|
|
44
|
+
Style/IfUnlessModifier:
|
|
45
|
+
Enabled: false
|
|
46
|
+
StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
|
|
47
|
+
|
|
48
|
+
Style/Lambda:
|
|
49
|
+
Enabled: false
|
|
50
|
+
StyleGuide: https://relaxed.ruby.style/#stylelambda
|
|
51
|
+
|
|
52
|
+
Style/ModuleFunction:
|
|
53
|
+
Enabled: false
|
|
54
|
+
StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
|
|
55
|
+
|
|
56
|
+
Style/MultilineBlockChain:
|
|
57
|
+
Enabled: false
|
|
58
|
+
StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
|
|
59
|
+
|
|
60
|
+
Style/NegatedIf:
|
|
61
|
+
Enabled: false
|
|
62
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedif
|
|
63
|
+
|
|
64
|
+
Style/NegatedWhile:
|
|
65
|
+
Enabled: false
|
|
66
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
|
67
|
+
|
|
68
|
+
Style/NumericPredicate:
|
|
69
|
+
Enabled: false
|
|
70
|
+
StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
|
|
71
|
+
|
|
72
|
+
Style/ParallelAssignment:
|
|
73
|
+
Enabled: false
|
|
74
|
+
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
|
75
|
+
|
|
76
|
+
Style/PercentLiteralDelimiters:
|
|
77
|
+
Enabled: false
|
|
78
|
+
StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
|
|
79
|
+
|
|
80
|
+
Style/PerlBackrefs:
|
|
81
|
+
Enabled: false
|
|
82
|
+
StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
|
|
83
|
+
|
|
84
|
+
Style/Semicolon:
|
|
85
|
+
Enabled: false
|
|
86
|
+
StyleGuide: https://relaxed.ruby.style/#stylesemicolon
|
|
87
|
+
|
|
88
|
+
Style/SignalException:
|
|
89
|
+
Enabled: false
|
|
90
|
+
StyleGuide: https://relaxed.ruby.style/#stylesignalexception
|
|
91
|
+
|
|
92
|
+
Style/SingleLineBlockParams:
|
|
93
|
+
Enabled: false
|
|
94
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
|
|
95
|
+
|
|
96
|
+
Style/SingleLineMethods:
|
|
97
|
+
Enabled: false
|
|
98
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
|
|
99
|
+
|
|
100
|
+
Layout/SpaceBeforeBlockBraces:
|
|
101
|
+
Enabled: false
|
|
102
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
|
|
103
|
+
|
|
104
|
+
Layout/SpaceInsideParens:
|
|
105
|
+
Enabled: false
|
|
106
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
|
|
107
|
+
|
|
108
|
+
Style/SpecialGlobalVars:
|
|
109
|
+
Enabled: false
|
|
110
|
+
StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
|
|
111
|
+
|
|
112
|
+
Style/StringLiterals:
|
|
113
|
+
Enabled: false
|
|
114
|
+
StyleGuide: https://relaxed.ruby.style/#stylestringliterals
|
|
115
|
+
|
|
116
|
+
Style/TrailingCommaInArguments:
|
|
117
|
+
Enabled: false
|
|
118
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
|
|
119
|
+
|
|
120
|
+
Style/TrailingCommaInArrayLiteral:
|
|
121
|
+
Enabled: false
|
|
122
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
|
|
123
|
+
|
|
124
|
+
Style/TrailingCommaInHashLiteral:
|
|
125
|
+
Enabled: false
|
|
126
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
|
|
127
|
+
|
|
128
|
+
Style/SymbolArray:
|
|
129
|
+
Enabled: false
|
|
130
|
+
StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
|
|
131
|
+
|
|
132
|
+
Style/WhileUntilModifier:
|
|
133
|
+
Enabled: false
|
|
134
|
+
StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
|
|
135
|
+
|
|
136
|
+
Style/WordArray:
|
|
137
|
+
Enabled: false
|
|
138
|
+
StyleGuide: https://relaxed.ruby.style/#stylewordarray
|
|
139
|
+
|
|
140
|
+
Lint/AmbiguousRegexpLiteral:
|
|
141
|
+
Enabled: false
|
|
142
|
+
StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
|
|
143
|
+
|
|
144
|
+
Lint/AssignmentInCondition:
|
|
145
|
+
Enabled: false
|
|
146
|
+
StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
|
|
147
|
+
|
|
148
|
+
Layout/LineLength:
|
|
149
|
+
Enabled: false
|
|
150
|
+
|
|
151
|
+
Metrics:
|
|
152
|
+
Enabled: false
|
|
153
|
+
|
data/.rubocop.yml
CHANGED
|
@@ -4,7 +4,7 @@ inherit_from:
|
|
|
4
4
|
inherit_gem:
|
|
5
5
|
prettier: rubocop.yml
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
plugins:
|
|
8
8
|
- rubocop-performance
|
|
9
9
|
|
|
10
10
|
AllCops:
|
|
@@ -27,9 +27,9 @@ Metrics/BlockLength:
|
|
|
27
27
|
Lint/EmptyBlock:
|
|
28
28
|
Enabled: false
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
# Development dependencies in gemspec is a valid pattern for gems
|
|
31
|
+
Gemspec/DevelopmentDependencies:
|
|
32
|
+
Enabled: false
|
|
33
33
|
|
|
34
34
|
### Prettier
|
|
35
35
|
Style/OptionalBooleanParameter:
|
|
@@ -38,6 +38,14 @@ Style/OptionalBooleanParameter:
|
|
|
38
38
|
Style/GuardClause:
|
|
39
39
|
Enabled: false
|
|
40
40
|
|
|
41
|
+
# We legitimately reopen RSpec in multiple files and define separate helper modules
|
|
42
|
+
Style/OneClassPerFile:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# Ruby >= 3.2 required, frozen string literal comment is unnecessary noise
|
|
46
|
+
Style/FrozenStringLiteralComment:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
41
49
|
### End Prettier
|
|
42
50
|
Naming/MethodParameterName:
|
|
43
51
|
Enabled: false
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.1
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.1] - 2026-03-05
|
|
10
|
+
### Added
|
|
11
|
+
- `LLMS.md` — comprehensive API reference for LLMs
|
|
12
|
+
- `examples/` directory with real-world usage patterns (contexts and specs)
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Complete rewrite of `README.md` with better structure, real-world examples, and comparison with `shared_examples`
|
|
16
|
+
|
|
17
|
+
## [1.2.0] - 2026-01-27
|
|
18
|
+
### Breaking
|
|
19
|
+
- **BREAKING** Minimum Ruby version is now 3.2
|
|
20
|
+
- **BREAKING** `in_context` without namespace now raises `AmbiguousContextName` if the same context name exists in multiple namespaces. Specify the namespace explicitly to resolve.
|
|
21
|
+
- Removed `codacy-coverage` dependency (incompatible with Ruby 4)
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Nested `in_context` with blocks now work correctly (uses a stack instead of a single thread-local variable)
|
|
25
|
+
- Input validation: `define_context` raises `InvalidContextName` for nil/empty names and `MissingDefinitionBlock` when no block is given
|
|
26
|
+
- `AmbiguousContextName` error when a context name exists in multiple namespaces and no namespace is specified
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- CI now tests Ruby 3.2, 3.3, 3.4, and head
|
|
30
|
+
- GitHub Actions updated to v4 (checkout, setup-node)
|
|
31
|
+
- Node updated to 20 in CI
|
|
32
|
+
- Rubocop config uses `plugins` instead of deprecated `require`
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- Thread-safety for nested `in_context` calls with blocks (previous implementation silently overwrote the outer block)
|
|
36
|
+
- Non-deterministic context resolution when multiple namespaces contained the same context name
|
|
37
|
+
- Tests no longer depend on execution order (random order enabled)
|
|
38
|
+
- Removed all global variables from test suite
|
|
39
|
+
|
|
9
40
|
## [1.1.0.3] - 2021-01-13
|
|
10
41
|
### Added
|
|
11
42
|
- Reformating code with Prettier-ruby
|
|
@@ -30,7 +61,11 @@ This is a release in order to test all type of actions
|
|
|
30
61
|
- Changelog
|
|
31
62
|
- Support ruby 3.0
|
|
32
63
|
|
|
33
|
-
[Unreleased]: https://github.com/zaratan/rspec_in_context/compare/v1.
|
|
64
|
+
[Unreleased]: https://github.com/zaratan/rspec_in_context/compare/v1.2.1...HEAD
|
|
65
|
+
[1.2.1]: https://github.com/zaratan/rspec_in_context/compare/v1.2.0...v1.2.1
|
|
66
|
+
[1.2.0]: https://github.com/zaratan/rspec_in_context/compare/v1.1.0.3...v1.2.0
|
|
67
|
+
[1.1.0.3]: https://github.com/zaratan/rspec_in_context/compare/v1.1.0.2...v1.1.0.3
|
|
68
|
+
[1.1.0.2]: https://github.com/zaratan/rspec_in_context/compare/v1.1.0.1...v1.1.0.2
|
|
34
69
|
[1.1.0.1]: https://github.com/zaratan/rspec_in_context/releases/tag/v1.1.0.1
|
|
35
70
|
[1.1.0]: https://github.com/zaratan/rspec_in_context/releases/tag/v1.1.0
|
|
36
71
|
[1.0.1.2]: https://github.com/zaratan/rspec_in_context/releases/tag/v1.0.1.2
|