backspin 0.4.0 → 0.4.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/CLAUDE.md +2 -2
- data/CONTRIBUTING.md +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +7 -2
- data/fixtures/backspin/all_mode_filter.yml +14 -0
- data/fixtures/backspin/credential_filter.yml +18 -0
- data/fixtures/backspin/echo_hello.yml +14 -0
- data/fixtures/backspin/echo_verify.yml +14 -0
- data/fixtures/backspin/episodes_filter.yml +26 -0
- data/fixtures/backspin/failure_test.yml +14 -0
- data/fixtures/backspin/full_data_filter.yml +17 -0
- data/fixtures/backspin/mixed_calls.yml +24 -0
- data/fixtures/backspin/multi_command.yml +34 -0
- data/fixtures/backspin/multi_command_filter.yml +26 -0
- data/fixtures/backspin/multi_field_filter.yml +13 -0
- data/fixtures/backspin/multi_system.yml +20 -0
- data/fixtures/backspin/nil_filter.yml +14 -0
- data/fixtures/backspin/none_mode_test.yml +14 -0
- data/fixtures/backspin/path_test.yml +17 -0
- data/fixtures/backspin/playback_system.yml +12 -0
- data/fixtures/backspin/playback_test.yml +14 -0
- data/fixtures/backspin/stderr_test.yml +19 -0
- data/fixtures/backspin/system_echo.yml +12 -0
- data/fixtures/backspin/system_false.yml +18 -0
- data/fixtures/backspin/timestamp_test.yml +18 -0
- data/fixtures/backspin/use_record_filter.yml +15 -0
- data/fixtures/backspin/verify_system.yml +12 -0
- data/fixtures/backspin/verify_system_diff.yml +11 -0
- data/fixtures/backspin/version_test.yml +14 -0
- data/lib/backspin/version.rb +1 -1
- data/lib/backspin.rb +2 -2
- metadata +26 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f44a53c1983fd41c2660bc9652c158b2193e880e0e1339fa49c882d26fdd0852
|
4
|
+
data.tar.gz: 3b53d9ba92db35ad66c128bc049762e06c307472827fe2d4b795427c7e668bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28909c63f9befbe8a0ae208328b9c527b3f1ca28417a66e96afad6ee9be41c2fa157ede63e4c5073f049ac59ab9c336a5fde7b97e109b7efc61480942ddc1a58
|
7
|
+
data.tar.gz: e63c8c4fff6ac690575ffadfe48efd6b4d0bc2267680e1c99637a888edcf3034bb315d96efedc400bfabdf5f8a9aa7912dfef03771b86a6a69769efe1bdcaac6
|
data/CLAUDE.md
CHANGED
@@ -62,7 +62,7 @@ bin/rake standard # Run Standard Ruby linter
|
|
62
62
|
### Testing Approach
|
63
63
|
|
64
64
|
- Integration-focused tests that exercise the full stack
|
65
|
-
- Default record directory is `
|
65
|
+
- Default record directory is `fixtures/backspin` (can be configured)
|
66
66
|
- Tests use real shell commands (`echo`, `date`, etc.)
|
67
67
|
- Configuration is reset between tests to avoid side effects
|
68
68
|
- **Important**: Backspin specs MUST be as local and un-DRY as possible. Each spec should be self-contained with its own setup, expectations, and cleanup if needed. Avoid shared contexts or helpers that hide important test details.
|
@@ -76,7 +76,7 @@ bin/rake standard # Run Standard Ruby linter
|
|
76
76
|
4. Run tests with `rake spec`
|
77
77
|
|
78
78
|
### Debugging Tests
|
79
|
-
- Records are saved to `
|
79
|
+
- Records are saved to `fixtures/backspin/` by default
|
80
80
|
- Check YAML files to see recorded command outputs
|
81
81
|
|
82
82
|
### Updating Credential Patterns
|
data/CONTRIBUTING.md
CHANGED
@@ -99,7 +99,7 @@ Backspin is a Ruby gem for characterization testing of command-line interfaces.
|
|
99
99
|
|
100
100
|
#### Debugging Tests
|
101
101
|
|
102
|
-
- Records are saved to `
|
102
|
+
- Records are saved to `fixtures/backspin/` by default
|
103
103
|
- Check YAML files to see recorded command outputs
|
104
104
|
|
105
105
|
## Testing
|
@@ -125,7 +125,7 @@ Backspin uses integration-focused tests that exercise the full stack. When writi
|
|
125
125
|
- Avoid shared contexts or helpers that hide important test details
|
126
126
|
- Use real shell commands (`echo`, `date`, etc.) for testing
|
127
127
|
- Ensure configuration is reset between tests to avoid side effects
|
128
|
-
- Verify new or updated test records in `
|
128
|
+
- Verify new or updated test records in `fixtures/backspin/`
|
129
129
|
|
130
130
|
Example test structure:
|
131
131
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
# Backspin
|
1
|
+
# Backspin
|
2
|
+
|
3
|
+
[](https://www.ruby-lang.org/)
|
4
|
+
[](https://rubygems.org/gems/backspin)
|
5
|
+
[](https://circleci.com/gh/rsanheim/backspin)
|
6
|
+
[](https://github.com/rsanheim/backspin/commits/main)
|
2
7
|
|
3
8
|
Backspin records and replays CLI interactions in Ruby for easy snapshot testing of command-line interfaces. Currently supports `Open3.capture3` and `system` and requires `rspec-mocks`. More system calls and test integrations are welcome - send a PR!
|
4
9
|
|
@@ -62,7 +67,7 @@ end
|
|
62
67
|
result = Backspin.run("echo_test", mode: :record) do
|
63
68
|
Open3.capture3("echo hello")
|
64
69
|
end
|
65
|
-
# This will save the output to `
|
70
|
+
# This will save the output to `fixtures/backspin/echo_test.yml`.
|
66
71
|
|
67
72
|
# Explicit verify mode: Always verify against existing recording
|
68
73
|
result = Backspin.run("echo_test", mode: :verify) do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'My"
|
9
|
+
- API
|
10
|
+
- key
|
11
|
+
- is
|
12
|
+
- "********************'"
|
13
|
+
stdout: 'MY API KEY IS ********************
|
14
|
+
|
15
|
+
'
|
16
|
+
stderr: ''
|
17
|
+
status: 0
|
18
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'episode"
|
9
|
+
- 1'
|
10
|
+
stdout: 'EPISODE 1
|
11
|
+
|
12
|
+
'
|
13
|
+
stderr: ''
|
14
|
+
status: 0
|
15
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
16
|
+
- command_type: Open3::Capture3
|
17
|
+
args:
|
18
|
+
- echo
|
19
|
+
- "'episode"
|
20
|
+
- 2'
|
21
|
+
stdout: 'EPISODE 2
|
22
|
+
|
23
|
+
'
|
24
|
+
stderr: ''
|
25
|
+
status: 0
|
26
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- bash
|
8
|
+
- "-c"
|
9
|
+
- echo 'stdout message' && echo 'stderr message' >&2 && exit 42
|
10
|
+
stdout: 'stdout message
|
11
|
+
|
12
|
+
'
|
13
|
+
stderr: 'stderr message
|
14
|
+
|
15
|
+
'
|
16
|
+
status: 42
|
17
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Kernel::System
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- from
|
9
|
+
- system
|
10
|
+
stdout: ''
|
11
|
+
stderr: ''
|
12
|
+
status: 0
|
13
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
14
|
+
- command_type: Open3::Capture3
|
15
|
+
args:
|
16
|
+
- echo
|
17
|
+
- from
|
18
|
+
- capture3
|
19
|
+
stdout: 'from capture3
|
20
|
+
|
21
|
+
'
|
22
|
+
stderr: ''
|
23
|
+
status: 0
|
24
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- first
|
9
|
+
stdout: 'first
|
10
|
+
|
11
|
+
'
|
12
|
+
stderr: ''
|
13
|
+
status: 0
|
14
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
15
|
+
- command_type: Open3::Capture3
|
16
|
+
args:
|
17
|
+
- echo
|
18
|
+
- second
|
19
|
+
stdout: 'second
|
20
|
+
|
21
|
+
'
|
22
|
+
stderr: ''
|
23
|
+
status: 0
|
24
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
25
|
+
- command_type: Open3::Capture3
|
26
|
+
args:
|
27
|
+
- echo
|
28
|
+
- third
|
29
|
+
stdout: 'third
|
30
|
+
|
31
|
+
'
|
32
|
+
stderr: ''
|
33
|
+
status: 0
|
34
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'Count:"
|
9
|
+
- 42'
|
10
|
+
stdout: 'Count: X
|
11
|
+
|
12
|
+
'
|
13
|
+
stderr: ''
|
14
|
+
status: 0
|
15
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
16
|
+
- command_type: Open3::Capture3
|
17
|
+
args:
|
18
|
+
- echo
|
19
|
+
- "'Total:"
|
20
|
+
- 100'
|
21
|
+
stdout: 'Total: X
|
22
|
+
|
23
|
+
'
|
24
|
+
stderr: ''
|
25
|
+
status: 0
|
26
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- bash
|
8
|
+
- "-c"
|
9
|
+
- echo 'out' && echo 'err' >&2 && exit 1
|
10
|
+
stdout: modified stdout
|
11
|
+
stderr: modified stderr
|
12
|
+
status: 0
|
13
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Kernel::System
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- first
|
9
|
+
stdout: ''
|
10
|
+
stderr: ''
|
11
|
+
status: 0
|
12
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
13
|
+
- command_type: Kernel::System
|
14
|
+
args:
|
15
|
+
- echo
|
16
|
+
- second
|
17
|
+
stdout: ''
|
18
|
+
stderr: ''
|
19
|
+
status: 0
|
20
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'File"
|
9
|
+
- saved
|
10
|
+
- to
|
11
|
+
- "/Users/testuser/project/output.txt'"
|
12
|
+
stdout: 'File saved to PROJECT_ROOT/output.txt
|
13
|
+
|
14
|
+
'
|
15
|
+
stderr: ''
|
16
|
+
status: 0
|
17
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- sh
|
8
|
+
- "-c"
|
9
|
+
- "'echo"
|
10
|
+
- error
|
11
|
+
- ">&2;"
|
12
|
+
- exit
|
13
|
+
- 1'
|
14
|
+
stdout: ''
|
15
|
+
stderr: 'error
|
16
|
+
|
17
|
+
'
|
18
|
+
status: 1
|
19
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Kernel::System
|
6
|
+
args:
|
7
|
+
- 'true'
|
8
|
+
stdout: ''
|
9
|
+
stderr: ''
|
10
|
+
status: 0
|
11
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
12
|
+
- command_type: Kernel::System
|
13
|
+
args:
|
14
|
+
- 'false'
|
15
|
+
stdout: ''
|
16
|
+
stderr: ''
|
17
|
+
status: 1
|
18
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'Test"
|
9
|
+
- run
|
10
|
+
- at
|
11
|
+
- '2024-01-15'
|
12
|
+
- 10:30:45'
|
13
|
+
stdout: 'Test run at TIMESTAMP
|
14
|
+
|
15
|
+
'
|
16
|
+
stderr: ''
|
17
|
+
status: 0
|
18
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- echo
|
8
|
+
- "'hello"
|
9
|
+
- world'
|
10
|
+
stdout: 'HELLO WORLD
|
11
|
+
|
12
|
+
'
|
13
|
+
stderr: ''
|
14
|
+
status: 0
|
15
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
first_recorded_at: '2025-05-01T12:00:00Z'
|
3
|
+
format_version: '2.0'
|
4
|
+
commands:
|
5
|
+
- command_type: Open3::Capture3
|
6
|
+
args:
|
7
|
+
- ruby
|
8
|
+
- "--version"
|
9
|
+
stdout: 'ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [arm64-darwin24]
|
10
|
+
|
11
|
+
'
|
12
|
+
stderr: ''
|
13
|
+
status: 0
|
14
|
+
recorded_at: '2025-05-01T12:00:00Z'
|
data/lib/backspin/version.rb
CHANGED
data/lib/backspin.rb
CHANGED
@@ -21,7 +21,7 @@ module Backspin
|
|
21
21
|
# Configuration for Backspin
|
22
22
|
class Configuration
|
23
23
|
attr_accessor :scrub_credentials
|
24
|
-
# The directory where backspin will store its files - defaults to
|
24
|
+
# The directory where backspin will store its files - defaults to fixtures/backspin
|
25
25
|
attr_accessor :backspin_dir
|
26
26
|
# Regex patterns to scrub from saved output
|
27
27
|
attr_reader :credential_patterns
|
@@ -29,7 +29,7 @@ module Backspin
|
|
29
29
|
def initialize
|
30
30
|
@scrub_credentials = true
|
31
31
|
@credential_patterns = default_credential_patterns
|
32
|
-
@backspin_dir = Pathname(Dir.pwd).join("
|
32
|
+
@backspin_dir = Pathname(Dir.pwd).join("fixtures", "backspin")
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_credential_pattern(pattern)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backspin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Sanheim
|
@@ -62,6 +62,31 @@ files:
|
|
62
62
|
- bin/rake
|
63
63
|
- bin/rspec
|
64
64
|
- bin/setup
|
65
|
+
- fixtures/backspin/all_mode_filter.yml
|
66
|
+
- fixtures/backspin/credential_filter.yml
|
67
|
+
- fixtures/backspin/echo_hello.yml
|
68
|
+
- fixtures/backspin/echo_verify.yml
|
69
|
+
- fixtures/backspin/episodes_filter.yml
|
70
|
+
- fixtures/backspin/failure_test.yml
|
71
|
+
- fixtures/backspin/full_data_filter.yml
|
72
|
+
- fixtures/backspin/mixed_calls.yml
|
73
|
+
- fixtures/backspin/multi_command.yml
|
74
|
+
- fixtures/backspin/multi_command_filter.yml
|
75
|
+
- fixtures/backspin/multi_field_filter.yml
|
76
|
+
- fixtures/backspin/multi_system.yml
|
77
|
+
- fixtures/backspin/nil_filter.yml
|
78
|
+
- fixtures/backspin/none_mode_test.yml
|
79
|
+
- fixtures/backspin/path_test.yml
|
80
|
+
- fixtures/backspin/playback_system.yml
|
81
|
+
- fixtures/backspin/playback_test.yml
|
82
|
+
- fixtures/backspin/stderr_test.yml
|
83
|
+
- fixtures/backspin/system_echo.yml
|
84
|
+
- fixtures/backspin/system_false.yml
|
85
|
+
- fixtures/backspin/timestamp_test.yml
|
86
|
+
- fixtures/backspin/use_record_filter.yml
|
87
|
+
- fixtures/backspin/verify_system.yml
|
88
|
+
- fixtures/backspin/verify_system_diff.yml
|
89
|
+
- fixtures/backspin/version_test.yml
|
65
90
|
- lib/backspin.rb
|
66
91
|
- lib/backspin/command.rb
|
67
92
|
- lib/backspin/command_diff.rb
|