spec/octopolo/github/pull_request_spec.rb in octopolo-0.3.6 vs spec/octopolo/github/pull_request_spec.rb in octopolo-0.4.0
- old
+ new
@@ -18,11 +18,11 @@
pr.number.should == pr_number
end
it "optionally accepts the github data" do
pr = PullRequest.new repo_name, pr_number, octo
- pr.pull_request_data.should == octo
+ pr.data.should == octo
end
it "fails if not given a repo name" do
expect { PullRequest.new nil, pr_number }.to raise_error(PullRequest::MissingParameter)
end
@@ -30,35 +30,35 @@
it "fails if not given a pull request number" do
expect { PullRequest.new repo_name, nil }.to raise_error(PullRequest::MissingParameter)
end
end
- context "#pull_request_data" do
+ context "#data" do
let(:pull) { PullRequest.new repo_name, pr_number }
it "fetches the details from GitHub" do
GitHub.should_receive(:pull_request).with(pull.repo_name, pull.number) { octo }
- pull.pull_request_data.should == octo
+ pull.data.should == octo
end
it "catches the information" do
GitHub.should_receive(:pull_request).once { octo }
- pull.pull_request_data
- pull.pull_request_data
+ pull.data
+ pull.data
end
it "fails if given invalid information" do
GitHub.should_receive(:pull_request).and_raise(Octokit::NotFound)
- expect { pull.pull_request_data }.to raise_error(PullRequest::NotFound)
+ expect { pull.data }.to raise_error(PullRequest::NotFound)
end
end
context "fetching its attributes from Octokit" do
let(:pull) { PullRequest.new repo_name, pr_number }
before do
- pull.stub(pull_request_data: octo)
+ pull.stub(data: octo)
end
context "#title" do
let(:octo) { stub(title: "the title") }
@@ -128,15 +128,15 @@
let(:comment1) { stub(user: stub(login: "pbyrne")) }
let(:comment2) { stub(user: stub(login: "anfleene")) }
before do
pull.stub(comments: [comment1, comment2], author_names: [])
+ GitHub::User.stub(:new).with("pbyrne").and_return(stub(:author_name => "pbyrne"))
+ GitHub::User.stub(:new).with("anfleene").and_return(stub(:author_name => "anfleene"))
end
it "returns the names of the commit authors" do
- GitHub.stub(:user).with("pbyrne").and_return(Hashie::Mash.new(:name => "pbyrne"))
- GitHub.stub(:user).with("anfleene").and_return(Hashie::Mash.new(:name => "anfleene"))
names = pull.commenter_names
names.should_not be_empty
names.size.should == 2
names.first.should == "pbyrne"
end
@@ -158,12 +158,12 @@
context "#without_octopolo_users" do
let(:users) { ["anfleene", "tst-octopolo"] }
it "excludes the github octopolo users" do
- pull.exlude_octopolo_user(users).should_not include("tst-octopolo")
- pull.exlude_octopolo_user(users).should include("anfleene")
+ pull.exclude_octopolo_user(users).should_not include("tst-octopolo")
+ pull.exclude_octopolo_user(users).should include("anfleene")
end
end
context "#url" do
let(:octo) { stub(html_url: "http://example.com") }
@@ -274,17 +274,17 @@
end
context ".create repo_name, options" do
let(:options) { stub(:hash) }
let(:number) { stub(:integer) }
- let(:pull_request_data) { stub(:pull_request_data)}
- let(:creator) { stub(:pull_request_creator, number: number, pull_request_data: pull_request_data)}
+ let(:data) { stub(:data)}
+ let(:creator) { stub(:pull_request_creator, number: number, data: data)}
let(:pull_request) { stub(:pull_request) }
it "passes on to PullRequestCreator and returns a new PullRequest" do
PullRequestCreator.should_receive(:perform).with(repo_name, options) { creator }
- PullRequest.should_receive(:new).with(repo_name, number, pull_request_data) { pull_request }
+ PullRequest.should_receive(:new).with(repo_name, number, data) { pull_request }
PullRequest.create(repo_name, options).should == pull_request
end
end
context "labeling" do
@@ -293,16 +293,16 @@
let(:pull_request) { PullRequest.new repo_name, pr_number }
context "#add_labels" do
it "sends the correct arguments to add_labels_to_pull for multiple labels" do
allow(Label).to receive(:build_label_array) {[label1,label2]}
- expect(GitHub).to receive(:add_labels_to_pull).with(repo_name, pr_number, ["low-risk","high-risk"])
+ expect(GitHub).to receive(:add_labels_to_issue).with(repo_name, pr_number, ["low-risk","high-risk"])
pull_request.add_labels([label1, label2])
end
it "sends the correct arguments to add_labels_to_pull for a single label" do
allow(Label).to receive(:build_label_array) {[label1]}
- expect(GitHub).to receive(:add_labels_to_pull).with(repo_name, pr_number, ["low-risk"])
+ expect(GitHub).to receive(:add_labels_to_issue).with(repo_name, pr_number, ["low-risk"])
pull_request.add_labels(label1)
end
end
context "#remove_from_pull" do