diff options
| author | Markus Reiter | 2017-02-16 21:17:46 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-02-19 18:41:53 +0100 |
| commit | 05a98f24c4d21b3a3c7fcb4045e74619a4628f4c (patch) | |
| tree | 4b48a58a7d392fc963681745c445a9cf2dc49e8f /Library/Homebrew/test/utils | |
| parent | 9f31d41fb263718bff98e194df411b8aaea72aba (diff) | |
| download | brew-05a98f24c4d21b3a3c7fcb4045e74619a4628f4c.tar.bz2 | |
Convert Utils test to spec.
Diffstat (limited to 'Library/Homebrew/test/utils')
| -rw-r--r-- | Library/Homebrew/test/utils/bottles/bintray_spec.rb | 18 | ||||
| -rw-r--r-- | Library/Homebrew/test/utils/popen_spec.rb | 28 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Library/Homebrew/test/utils/bottles/bintray_spec.rb b/Library/Homebrew/test/utils/bottles/bintray_spec.rb new file mode 100644 index 000000000..a7dfc00ea --- /dev/null +++ b/Library/Homebrew/test/utils/bottles/bintray_spec.rb @@ -0,0 +1,18 @@ +require "utils/bottles" + +describe Utils::Bottles::Bintray do + describe "::package" do + it "converts a Formula name to a package name" do + expect(described_class.package("openssl@1.1")).to eq("openssl:1.1") + expect(described_class.package("gtk+")).to eq("gtkx") + expect(described_class.package("llvm")).to eq("llvm") + end + end + + describe "::repository" do + it "returns the repository for a given Tap" do + expect(described_class.repository(Tap.new("homebrew", "bintray-test"))) + .to eq("bottles-bintray-test") + end + end +end 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 |
