taski 0.9.2 → 0.10.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +28 -0
- data/lib/taski/task.rb +5 -2
- data/lib/taski/test_helper.rb +2 -17
- data/lib/taski/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b71f6af24c3542cbbb646bb6c19b15dfb5418c98b0e7799185e0ec260f0ba976
|
|
4
|
+
data.tar.gz: 31b9ff2f2f6c8b7a872381f7e1ba93ba59174bb3bf060a2294ba067bf2983a4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52daee905c66f2330bc9ee00c2ac2a71aeaf95cb2057feb0757588e0dff379010fa0a8e396e5ee0290b45f12fa134b92d6abdcfbaa9a37e57e454e8b231743b8
|
|
7
|
+
data.tar.gz: 2ffdecd55d9b0c8a6a39299b4f9ff2c13ca5c88952b16535ef6008a765eded237911d711d72f47cb57e58d0d612a743dacb07b3162e2dde075aaba29952e04ad
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.10.0] - 2026-02-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Accept `args:` keyword parameter in `Task.value` and class accessor methods generated by `exports` ([#185](https://github.com/ahogappa/taski/pull/185))
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Forward `args:` keyword through `TaskExtension` in test helper, removing `mock_args` ([#185](https://github.com/ahogappa/taski/pull/185))
|
|
17
|
+
|
|
10
18
|
## [0.9.2] - 2026-02-16
|
|
11
19
|
|
|
12
20
|
### Added
|
data/README.md
CHANGED
|
@@ -248,8 +248,13 @@ end
|
|
|
248
248
|
|
|
249
249
|
# Pass options when running
|
|
250
250
|
DeployTask.run(args: { env: "production", debug: true })
|
|
251
|
+
|
|
252
|
+
# Args can also be passed to exported class methods
|
|
253
|
+
Config.timeout(args: { env: "test" })
|
|
251
254
|
```
|
|
252
255
|
|
|
256
|
+
**Note:** `args:` is only accepted at the top-level call that starts an execution. If `args:` is passed to a dependency access inside a running task (e.g., `DepTask.value(args: {...})`), the args are ignored and a warning is emitted.
|
|
257
|
+
|
|
253
258
|
Args API (user-defined options):
|
|
254
259
|
- `Taski.args[:key]` - Get option value (nil if not set)
|
|
255
260
|
- `Taski.args.fetch(:key, default)` - Get with default value
|
|
@@ -424,8 +429,31 @@ class BuildReportTest < Minitest::Test
|
|
|
424
429
|
end
|
|
425
430
|
```
|
|
426
431
|
|
|
432
|
+
### Passing Args in Tests
|
|
433
|
+
|
|
434
|
+
Pass `args:` directly to task class methods instead of setting global state:
|
|
435
|
+
|
|
436
|
+
```ruby
|
|
437
|
+
class DeployTaskTest < Minitest::Test
|
|
438
|
+
include Taski::TestHelper::Minitest
|
|
439
|
+
|
|
440
|
+
def test_deploy_to_staging
|
|
441
|
+
mock_task(FetchConfig, url: "https://staging.example.com")
|
|
442
|
+
|
|
443
|
+
# Pass args directly - no global state needed
|
|
444
|
+
DeployTask.run(args: { env: "staging", debug: true })
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def test_exported_value_with_args
|
|
448
|
+
result = Config.timeout(args: { env: "test" })
|
|
449
|
+
assert_equal 30, result
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
```
|
|
453
|
+
|
|
427
454
|
**Key features:**
|
|
428
455
|
- Mock only direct dependencies; indirect dependencies are automatically isolated
|
|
456
|
+
- Pass `args:` directly to `Task.run`, `Task.value`, and exported class methods
|
|
429
457
|
- Verify which dependencies were accessed with `assert_task_accessed` / `refute_task_accessed`
|
|
430
458
|
- Automatic cleanup after each test
|
|
431
459
|
- Supports both Minitest and RSpec
|
data/lib/taski/task.rb
CHANGED
|
@@ -178,9 +178,12 @@ module Taski
|
|
|
178
178
|
def define_class_accessor(method)
|
|
179
179
|
singleton_class.undef_method(method) if singleton_class.method_defined?(method)
|
|
180
180
|
|
|
181
|
-
define_singleton_method(method) do
|
|
181
|
+
define_singleton_method(method) do |args: {}|
|
|
182
182
|
registry = Taski.current_registry
|
|
183
183
|
if registry
|
|
184
|
+
unless args.empty?
|
|
185
|
+
warn "Taski: args: passed to #{self}.#{method} is ignored inside an execution context"
|
|
186
|
+
end
|
|
184
187
|
if Thread.current[:taski_fiber_context]
|
|
185
188
|
start_deps = Thread.current[:taski_start_deps]
|
|
186
189
|
if start_deps&.include?(self)
|
|
@@ -208,7 +211,7 @@ module Taski
|
|
|
208
211
|
else
|
|
209
212
|
# Outside execution - fresh execution (top-level call)
|
|
210
213
|
Taski.send(:with_env, root_task: self) do
|
|
211
|
-
Taski.send(:with_args, options:
|
|
214
|
+
Taski.send(:with_args, options: args) do
|
|
212
215
|
validate_no_circular_dependencies!
|
|
213
216
|
fresh_wrapper.get_exported_value(method)
|
|
214
217
|
end
|
data/lib/taski/test_helper.rb
CHANGED
|
@@ -26,11 +26,11 @@ module Taski
|
|
|
26
26
|
super
|
|
27
27
|
original_method = self.method(method)
|
|
28
28
|
|
|
29
|
-
define_singleton_method(method) do
|
|
29
|
+
define_singleton_method(method) do |args: {}|
|
|
30
30
|
mock = MockRegistry.mock_for(self)
|
|
31
31
|
return mock.get_exported_value(method) if mock
|
|
32
32
|
|
|
33
|
-
original_method.call
|
|
33
|
+
original_method.call(args: args)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -98,21 +98,6 @@ module Taski
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
# Sets mock args for the duration of the test.
|
|
102
|
-
# This allows testing code that depends on Taski.args without running full task execution.
|
|
103
|
-
# Args are automatically cleared when MockRegistry.reset! is called (in test teardown).
|
|
104
|
-
# @param options [Hash] User-defined options to include in args
|
|
105
|
-
# @return [Taski::Args] The created args instance
|
|
106
|
-
#
|
|
107
|
-
# @example
|
|
108
|
-
# mock_args(env: "test", debug: true)
|
|
109
|
-
# assert_equal "test", Taski.args[:env]
|
|
110
|
-
def mock_args(**options)
|
|
111
|
-
Taski.reset_args!
|
|
112
|
-
Taski.send(:start_args, options: options)
|
|
113
|
-
Taski.args
|
|
114
|
-
end
|
|
115
|
-
|
|
116
101
|
# Sets mock env for the duration of the test.
|
|
117
102
|
# This allows testing code that depends on Taski.env without running full task execution.
|
|
118
103
|
# Env is automatically cleared when MockRegistry.reset! is called (in test teardown).
|
data/lib/taski/version.rb
CHANGED