aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/dev-cmd/pull_spec.rb
blob: cc66df7830ab633733113803bc03d08788964b9d (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
describe "brew pull", :integration_test do
  it "fails when no argument is given" do
    expect { brew "pull" }
      .to output(/This command requires at least one argument/).to_stderr
      .and not_to_output.to_stdout
      .and be_a_failure
  end

  it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network, retry: 3 do
    CoreTap.instance.path.cd do
      system "git", "init"
      system "git", "checkout", "-b", "new-branch"
    end

    expect { brew "pull", "https://jenkins.brew.sh/job/Homebrew\%20Testing/1028/" }
      .to output(/Testing URLs require `\-\-bottle`!/).to_stderr
      .and not_to_output.to_stdout
      .and be_a_failure

    expect { brew "pull", "1" }
      .to output(/Fetching patch/).to_stdout
      .and output(/Current branch is new\-branch/).to_stderr
      .and be_a_failure

    expect { brew "pull", "--bump", "https://github.com/Homebrew/homebrew-core/pull/8" }
      .to output(/Fetching patch/).to_stdout
      .and output(/No changed formulae found to bump/).to_stderr
      .and be_a_failure

    expect { brew "pull", "--bump", "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122" }
      .to output(/Fetching patch/).to_stdout
      .and output(/Can only bump one changed formula/).to_stderr
      .and be_a_failure

    expect { brew "pull", "https://github.com/Homebrew/brew/pull/1249" }
      .to output(/Fetching patch/).to_stdout
      .and output(/Patch failed to apply/).to_stderr
      .and be_a_failure
  end

  describe "--rebase" do
    it "fails" do
      expect { brew "pull", "--rebase" }
        .to output(/You meant `git pull --rebase`./).to_stderr
        .and not_to_output.to_stdout
        .and be_a_failure
    end
  end

  it "fails when given 0" do
    expect { brew "pull", "0" }
      .to output(/Not a GitHub pull request or commit/).to_stderr
      .and not_to_output.to_stdout
      .and be_a_failure
  end
end