Sha256: fce6edaa33a15c464be440f4b1afacef4956a60c0fd8bacd785df0a7c5ba7531

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe Status::Github::PullRequest do
  subject { Status::Github::PullRequest.new }

  before do
    Status.stub(:config => stub(:attrs => {}))
  end

  context "#pull_request_found?" do
    before do
      Status::Request.stub(:new => stub(:get => [{"head" => {"ref" => "branch_name"}}]))
    end

    it "is not found if a pull request does not exists" do
      Status.stub(:branch => "new_branch")
      subject.pull_request_found?.should be_false
    end

    it "is found if a pull request does exists" do
      Status.stub(:branch => "branch_name")
      subject.pull_request_found?.should be_true
    end
  end

  context "#create_pull_request" do
    before do
      subject.stub(:puts)
      subject.stub(:gets => "y\n")
    end

    it "creates a pull request" do
      Status::Request.stub(:new => stub(:post => "{\"status\":\"success\"}"))
      subject.stub(:puts => "url")
      subject.create_pull_request.should == "url"
    end

    it "returns error msg when pull request creation fails" do
      Status::Request.stub(:new => stub(:post => "{\"message\":\"server error\"}"))
      subject.stub(:puts => "not found")
      subject.create_pull_request.should == "not found"
    end

    it "aborts pull request creation" do
      subject.stub(:gets => "n")
      subject.should_receive(:abort)
      subject.create_pull_request
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
update_status-0.1.7 spec/status/github/pull_request_spec.rb
update_status-0.1.6 spec/status/github/pull_request_spec.rb
update_status-0.1.5 spec/status/github/pull_request_spec.rb
update_status-0.1.4 spec/status/github/pull_request_spec.rb
update_status-0.1.3 spec/status/github/pull_request_spec.rb
update_status-0.1.2 spec/status/github/pull_request_spec.rb
update_status-0.1.1 spec/status/github/pull_request_spec.rb
update_status-0.1.0 spec/status/github/pull_request_spec.rb