diff options
Diffstat (limited to 'Library/Homebrew/test/cmd')
| -rw-r--r-- | Library/Homebrew/test/cmd/link_spec.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/cmd/outdated_spec.rb | 92 |
2 files changed, 88 insertions, 10 deletions
diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb index 7b85c96dc..59ab86cc4 100644 --- a/Library/Homebrew/test/cmd/link_spec.rb +++ b/Library/Homebrew/test/cmd/link_spec.rb @@ -48,9 +48,11 @@ describe "brew link", :integration_test do expect { brew "install", "testball1" }.to be_a_success end - expect { brew "link", "testball1" } + expect { brew "link", "testball1", "SHELL" => "/bin/zsh" } .to output(/testball1 is keg-only/).to_stderr - .and output(/Note that doing so can interfere with building software\./).to_stdout + .and output(a_string_matching(/Note that doing so can interfere with building software\./) + .and(matching("If you need to have this software first in your PATH instead consider running:") + .and(including("echo 'export PATH=\"#{HOMEBREW_PREFIX}/opt/testball1/bin:$PATH\"' >> ~/.zshrc")))).to_stdout .and be_a_success end end diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb index 2ce0825e8..65cce27c3 100644 --- a/Library/Homebrew/test/cmd/outdated_spec.rb +++ b/Library/Homebrew/test/cmd/outdated_spec.rb @@ -1,11 +1,87 @@ describe "brew outdated", :integration_test do - it "prints outdated Formulae" do - setup_test_formula "testball" - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - - expect { brew "outdated" } - .to output("testball\n").to_stdout - .and not_to_output.to_stderr - .and be_a_success + context "quiet output" do + it "prints outdated Formulae" do + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + expect { brew "outdated" } + .to output("testball\n").to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + end + + context "verbose output" do + it "prints out the installed and newer versions" do + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + expect { brew "outdated", "--verbose" } + .to output("testball (0.0.1) < 0.1\n").to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + end + + context "pinned formula, verbose output" do + it "prints out the pinned version" do + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + shutup do + expect { brew "pin", "testball" }.to be_a_success + end + + expect { brew "outdated", "--verbose" } + .to output("testball (0.0.1) < 0.1 [pinned at 0.0.1]\n").to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + end + + context "json output" do + it "includes pinned version in the json output" do + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + shutup do + expect { brew "pin", "testball" }.to be_a_success + end + + expected_json = [ + { + name: "testball", + installed_versions: ["0.0.1"], + current_version: "0.1", + pinned: true, + pinned_version: "0.0.1", + }, + ].to_json + + expect { brew "outdated", "--json=v1" } + .to output(expected_json + "\n").to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + + it "has no pinned version when the formula isn't pinned" do + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + expected_json = [ + { + name: "testball", + installed_versions: ["0.0.1"], + current_version: "0.1", + pinned: false, + pinned_version: nil, + }, + ].to_json + + expect { brew "outdated", "--json=v1" } + .to output(expected_json + "\n").to_stdout + .and not_to_output.to_stderr + .and be_a_success + end end end |
