spec/octopolo/github/label_spec.rb in octopolo-1.7.0 vs spec/octopolo/github/label_spec.rb in octopolo-1.7.1

- old
+ new

@@ -13,11 +13,12 @@ let(:config) { stub(:config, github_repo: "foo") } subject { Label } before do - subject.config = config + subject.config = config + allow(GitHub).to receive(:labels).and_return(labels_hash) end context "#initialize" do it "creates a label from a hash" do expect(Label.new(name: "low", color: "151515").name).to eq('low') @@ -25,24 +26,21 @@ end context "#all_labels" do it "gets and returns all labels belonging to a repository" do - allow(GitHub).to receive(:labels).and_return(labels_hash) expect(Label.all).to eq([label1,label2]) end end context "#first_or_create" do it "finds the existing label and doesn't do anything" do - allow(Label).to receive(:all_from_repo).and_return([label1,label2]) expect(GitHub).not_to receive(:add_label) Label.first_or_create(label1) end it "doesn't find a label and creates one" do - allow(Label).to receive(:all_from_repo).and_return([label1,label2]) expect(GitHub).to receive(:add_label).with(config.github_repo, "medium-risk", "454545") Label.first_or_create(Label.new(name: "medium-risk", color: "454545")) end end @@ -54,11 +52,10 @@ it "returns true if names are same ignoring color" do expect(label1 == label2).to eq(false) end end - context "#build_label_array" do it "returns an array of label when given a label" do allow(Label).to receive(:first_or_create) expect(Label.send(:build_label_array,label1)).to eq([label1]) end @@ -80,9 +77,15 @@ end context "#get_names" do it "returns a list of names when given an array of labels" do expect(Label.get_names([label1,label2])).to eq(["low-risk","high-risk"]) + end + end + + describe "#all_from_repo" do + it "should list all repos" do + expect(Label.send(:all_from_repo)).to eq([label1, label2]) end end end end end