aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/utils/popen_spec.rb
diff options
context:
space:
mode:
authorMike McQuaid2017-02-23 09:12:18 +0000
committerGitHub2017-02-23 09:12:18 +0000
commit1a436b4d24d50011bc444cf5d2016f5c0f808dec (patch)
tree9659fbe8f1ed557e74ddaf7fde9c3c8ff8821da2 /Library/Homebrew/test/utils/popen_spec.rb
parent5e9057500419d1a2b41efe784e9f12ae232e7f6e (diff)
parent3f8e52e5742cdd3d992ddee79741a4c4e45ab4bf (diff)
downloadbrew-1a436b4d24d50011bc444cf5d2016f5c0f808dec.tar.bz2
Merge branch 'master' into mirror_audit
Diffstat (limited to 'Library/Homebrew/test/utils/popen_spec.rb')
-rw-r--r--Library/Homebrew/test/utils/popen_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/Library/Homebrew/test/utils/popen_spec.rb b/Library/Homebrew/test/utils/popen_spec.rb
new file mode 100644
index 000000000..e3704a876
--- /dev/null
+++ b/Library/Homebrew/test/utils/popen_spec.rb
@@ -0,0 +1,28 @@
+require "utils/popen"
+
+describe Utils do
+ describe "::popen_read" do
+ it "reads the standard output of a given command" do
+ expect(subject.popen_read("sh", "-c", "echo success").chomp).to eq("success")
+ expect($?).to be_a_success
+ end
+
+ it "can be given a block to manually read from the pipe" do
+ expect(
+ subject.popen_read("sh", "-c", "echo success") do |pipe|
+ pipe.read.chomp
+ end,
+ ).to eq("success")
+ expect($?).to be_a_success
+ end
+ end
+
+ describe "::popen_write" do
+ it "with supports writing to a command's standard input" do
+ subject.popen_write("grep", "-q", "success") do |pipe|
+ pipe.write("success\n")
+ end
+ expect($?).to be_a_success
+ end
+ end
+end