aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/utils/popen_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-20 19:57:15 +0100
committerGitHub2017-02-20 19:57:15 +0100
commit7d855a539d2b52d12e449bd78fefbdb4be020767 (patch)
tree1aca9cb626a128416995f934404fecb433135ce4 /Library/Homebrew/test/utils/popen_spec.rb
parent3366ee7f51c4a7b52ec6e404d1c543e0ed44c137 (diff)
parent44d2617030f8407e74036decd93d94b33db881e7 (diff)
downloadbrew-7d855a539d2b52d12e449bd78fefbdb4be020767.tar.bz2
Merge pull request #2037 from reitermarkus/spec-utils
Convert Utils test to spec.
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