test-cmd.rb 2.6.0 → 2.7.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: 8f3880288c628fc25dc0a16dcee05222dc776ffb8cab098d2fad3610534ebded
4
- data.tar.gz: 39573f323c733d4fef70b3e784c3b6c4f956f7da60e0c1bbe7e454d51487f003
3
+ metadata.gz: c42ecb86960f6c733054ea3cd7ed041c23accec019f7addb7a2a595020b507bf
4
+ data.tar.gz: 05fd256aa2c70bb23e8e9ef3e3f8e91eb9bcff9fa2680f48a059960333e74b06
5
5
  SHA512:
6
- metadata.gz: 3b8e25c54804ac4cfa14f4356a2ea9f3e7b97f994792ae3f77b60e19151d3ee66d84959a40347b82adf1e0b5c277c3d28ef81b85992a5a496881db8e695ca867
7
- data.tar.gz: face7b9c865c69666ff8eb29393af0ce856777bdf70d617889021f3a8496c0d331be88c527eec3f861b606773d93b1ca70e634c7e08e4a12f60320d57777e5bd
6
+ metadata.gz: e2c4e2b3858f7b090359a46756a54408d28c729603f0f47ccda5a68c35e2c11dd807dade25cf79d88af938861a112b582d9ecea0198d4b2023ab6fba504ba63d
7
+ data.tar.gz: 7efb00552507bbbb2b1d66e599ccdd165e7acb3628f5a5e97daa2ec0bdafca5e63ebce274d937a737224836db806a171d4f8bbd07b2195bc092aa529ddacc2d8
data/README.md CHANGED
@@ -41,7 +41,7 @@ require "test-cmd"
41
41
  # Call the 'ls' command
42
42
  p Test::Command
43
43
  .new("ls")
44
- .argv("-l")
44
+ .arguments("-l")
45
45
  .stdout
46
46
 
47
47
  ##
@@ -65,8 +65,8 @@ p Test::Command
65
65
  # stderr. At most 20k bytes is read from both:
66
66
  p Test::Command
67
67
  .new("git")
68
+ .arguments("diff", "--cached")
68
69
  .limit(stdout: 20_000, stderr: 20_000)
69
- .argv("diff", "--cached")
70
70
  .stdout
71
71
  ```
72
72
 
@@ -4,5 +4,5 @@ end unless defined?(Test)
4
4
  class Test::Command
5
5
  ##
6
6
  # @string [String]
7
- VERSION = "2.6.0"
7
+ VERSION = "2.7.0"
8
8
  end
data/lib/test/command.rb CHANGED
@@ -38,12 +38,13 @@ class Test::Command
38
38
  end
39
39
 
40
40
  ##
41
- # @param [Array<String, #to_s>] argv
41
+ # @param [Array<String, #to_s>] arguments
42
42
  # Command-line arguments
43
43
  # @return [Test::Command]
44
- def argv(*argv)
45
- tap { @argv.concat(argv) }
44
+ def arguments(*arguments)
45
+ tap { @argv.concat(arguments) }
46
46
  end
47
+ alias_method :argv, :arguments
47
48
 
48
49
  ##
49
50
  # @param [Hash{String => String}] env
data/test/cmd_test.rb CHANGED
@@ -7,24 +7,41 @@ class Test::Command
7
7
  def ruby(str)
8
8
  ::Test::Command.new "ruby", "-e", str
9
9
  end
10
+
11
+ ##
12
+ # macos-specific env vars that are always set
13
+ # @return [String]
14
+ def macos
15
+ if ENV["__CF_USER_TEXT_ENCODING"]
16
+ "__CF_USER_TEXT_ENCODING\n"
17
+ else
18
+ ""
19
+ end
20
+ end
10
21
  end
11
22
  end
12
23
 
13
24
  class Test::Command
14
25
  ##
15
- # Test::Command#argv
16
- class ARGVTest < Test
17
- def test_ruby_argv
26
+ # Test::Command#arguments
27
+ class ArgumentsTest < Test
28
+ def test_ruby_arguments
18
29
  assert_equal "42\n", ::Test::Command.new("ruby")
19
- .argv("-e", "warn 42")
30
+ .arguments("-e", "warn 42")
20
31
  .stderr
21
32
  end
22
33
 
23
- def test_ruby_argv_to_s
34
+ def test_ruby_arguments_to_s
24
35
  arg = Object.new
25
36
  def arg.to_s = "-e"
26
37
  assert_equal "42\n", ::Test::Command.new("ruby")
27
- .argv(arg, "warn 42")
38
+ .arguments(arg, "warn 42")
39
+ .stderr
40
+ end
41
+
42
+ def test_ruby_arguments_argv_alias
43
+ assert_equal "42\n", ::Test::Command.new("ruby")
44
+ .argv("-e", "warn 42")
28
45
  .stderr
29
46
  end
30
47
  end
@@ -40,15 +57,15 @@ class Test::Command
40
57
  end
41
58
 
42
59
  def test_ruby_env_only_given_keys
43
- assert_equal "BAR\nFOO\nPATH\n",
60
+ assert_equal "BAR\nFOO\nPATH\n#{macos}",
44
61
  ::Test::Command.new("ruby", "-e", "puts ENV.keys.sort")
45
62
  .env("FOO" => "42", "BAR" => "7")
46
63
  .stdout
47
64
  end
48
65
 
49
66
  def test_ruby_env_empty_is_empty_env
50
- assert_equal "PATH",
51
- ::Test::Command.new("ruby", "-e", "print ENV.keys.sort.join(\",\")")
67
+ assert_equal "PATH\n#{macos}",
68
+ ::Test::Command.new("ruby", "-e", "puts ENV.keys.sort")
52
69
  .env({})
53
70
  .stdout
54
71
  end
data/test-cmd.rb.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.name = "test-cmd.rb"
7
7
  gem.authors = ["Robert Gleeson"]
8
8
  gem.email = ["robert@r.uby.dev"]
9
- gem.homepage = "https://github.com/0x1eef/test-cmd.rb#readme"
9
+ gem.homepage = "https://github.com/r-uby-dev/test-cmd.rb#readme"
10
10
  gem.version = Test::Command::VERSION
11
11
  gem.required_ruby_version = ">= 3.0"
12
12
  gem.licenses = ["MIT"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-cmd.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson
@@ -106,7 +106,7 @@ files:
106
106
  - test-cmd.rb.gemspec
107
107
  - test/cmd_test.rb
108
108
  - test/setup.rb
109
- homepage: https://github.com/0x1eef/test-cmd.rb#readme
109
+ homepage: https://github.com/r-uby-dev/test-cmd.rb#readme
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 4.0.16
127
+ rubygems_version: 4.0.20
128
128
  specification_version: 4
129
129
  summary: test-cmd.rb is a Go-inspired, object-oriented interface for running commands
130
130
  on UNIX-like systems, in the spirit of Go's `os/exec`. A command can be built by