spec/status/github/statuses_spec.rb in update_status-0.1.7 vs spec/status/github/statuses_spec.rb in update_status-0.2.0

- old
+ new

@@ -1,38 +1,43 @@ require 'spec_helper' describe Status::Github::Statuses do before do - stub_const("Status::Jenkins", stub) + @jenkins = stub + stub_const("Status::Jenkins", @jenkins) end subject { Status::Github::Statuses } it "has a payload target URL of the ci server URL and the branch name" do + @jenkins.stub(:new => stub(:state => "success", :pass? => true)) Status.stub(:ci_url => "http://jenkins-ci.org", :branch => "feature_branch") - subject.new.send(:target_url).should == "http://jenkins-ci.org/job/feature_branch" + subject.new("pending", "feature_branch").send(:target_url).should == "http://jenkins-ci.org/job/feature_branch" end it "has a payload description of the ci state and qa status" do - Status::Jenkins.stub(:state => "success") - subject.new.send(:description).should == "Build status: success, QA pending" + @jenkins.stub(:new => stub(:state => "success")) + subject.new("pending", "feature_branch").send(:description).should == "Build status: success, QA pending" end it "has a payload pending state when ci is passing but qa hasn't passed" do - Status::Jenkins.stub(:pass? => true, :state => "pending") - subject.new.send(:state).should == "pending" + @jenkins.stub(:new => stub(:state => "pending", :pass? => true)) + subject.new("pending", "feature_branch").send(:state).should == "pending" end it "has a payload success state when ci is passing and qa has passed" do - Status::Jenkins.stub(:pass? => true, :state => "success") - subject.new("pass").send(:state).should == "success" + @jenkins.stub(:new => stub(:state => "success", :pass? => true)) + subject.new("pass", "feature_branch").send(:state).should == "success" end it "has a payload error state when ci has an error" do - Status::Jenkins.stub(:pass? => false, :state => "nothing") - subject.new("pass").send(:state).should == "error" + @jenkins.stub(:new => stub(:state => "nothing", :pass? => false)) + subject.new("pass", "feature_branch").send(:state).should == "error" end it "goes to the correct status api" do - Status.stub(:owner => "owner", :repo => "status", :sha => "99efgd", :token => "123") - subject.new.send(:status_api).should == "/repos/owner/status/statuses/99efgd?access_token=123" + @jenkins.stub(:new => stub) + Status.stub(:owner => "owner", :repo => "status", :token => "123", :ci_url => "") + status = subject.new("pending", "feature_branch") + status.stub(:sha => "99efgd") + status.send(:status_api).should == "/repos/owner/status/statuses/99efgd?access_token=123" end end \ No newline at end of file