aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cmd/outdated_spec.rb
blob: 65cce27c313a5d96443303f18dd7c8449f374025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
describe "brew outdated", :integration_test do
  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