spec/bamboo-client/remote_spec.rb in bamboo-client-0.0.1 vs spec/bamboo-client/remote_spec.rb in bamboo-client-0.0.2

- old
+ new

@@ -62,11 +62,11 @@ client.execute_build("fake-build-key").should == "true" end it "fetches a list of builds" do - document.should_receive(:objects_for).with("build", Remote::Build). + document.should_receive(:objects_for).with("build", Remote::Build, client). and_return(["some", "objects"]) http.should_receive(:post).with( "/api/rest/listBuildNames.action", :auth => "fake-token" @@ -74,11 +74,11 @@ client.builds.should == ["some", "objects"] end it "fetches a list of the latest builds for the given user" do - document.should_receive(:objects_for).with("build", Remote::Build). + document.should_receive(:objects_for).with("build", Remote::Build, client). and_return(["some", "objects"]) user = "fake-user" http.should_receive(:post).with( @@ -129,11 +129,13 @@ client.recently_completed_results_for_build("fake-key").should == %w[some results] end end # API calls describe Remote::Build do - let(:build) { Remote::Build.new(xml_fixture("build").css("build").first) } + let(:client) { mock(Remote) } + let(:doc) { xml_fixture("build").css("build").first } + let(:build) { Remote::Build.new(doc, client) } it "should know if the build is enabled" do build.should be_enabled end @@ -141,9 +143,29 @@ build.name.should == "Thrift - Default" end it "should know the key of the build" do build.key.should == "THRIFT-DEFAULT" + end + + it "should be able to fetch the latest results" do + client.should_receive(:latest_build_results).with build.key + build.latest_results + end + + it "should be able to execute the build" do + client.should_receive(:execute_build).with build.key + build.execute + end + + it "should be able to update and build" do + client.should_receive(:update_and_build).with build.key + build.update_and_build + end + + it "should be able to fetch recentyl completed results" do + client.should_receive(:recently_completed_results_for_build).with build.key + build.recently_completed_results end end # Remote::Build describe Remote::BuildResult do let(:doc) { xml_fixture("build_result").css("response").first }