require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe CruiseStatus do describe "on failed build" do before :each do stub( io = Object.new ).read { FAIL_RESPONSE } stub( Kernel ).open( 'ccrb.rss' ) { io } @status = CruiseStatus.new 'ccrb.rss' end it "parses the response correctly" do @status.failures.should == %w[failed] end it "#pass? is false" do @status.should_not be_pass end end describe "on passing build" do before :each do stub( io = Object.new ).read { PASS_RESPONSE } stub( Kernel ).open( 'ccrb.rss' ) { io } @status = CruiseStatus.new 'ccrb.rss' end it "parses the response correctly" do @status.failures.should == [] end it "#pass? is true" do @status.should be_pass end end describe "on failed connection to cruise" do before :each do stub( io = Object.new ).read { raise Exception, 'Cannot connect' } stub( Kernel ).open( 'ccrb.rss' ) { io } @status = CruiseStatus.new 'ccrb.rss' end it "#pass? is false" do @status.should_not be_pass end end end FAIL_RESPONSE = <<-EOS CruiseControl RSS feed http://localhost:3333/ CruiseControl projects and their build statuses en-us 10 failed build 1126 failed stuff Tue, 17 Jun 2008 22:12:46 Z http://localhost:3333/builds/failed/1126 http://localhost:3333/builds/failed/1126 passed build 1126 success stuff Tue, 17 Jun 2008 22:12:46 Z http://localhost:3333/builds/passed/1126 http://localhost:3333/builds/passed/1126 EOS FAIL_RESPONSE_ON_POINT_REVISION = <<-EOS CruiseControl RSS feed http://localhost:3333/ CruiseControl projects and their build statuses en-us 10 my_project build 1126.1 failed stuff Tue, 17 Jun 2008 22:12:46 Z http://localhost:3333/builds/failed/1126 http://localhost:3333/builds/failed/1126 EOS PASS_RESPONSE = <<-EOS CruiseControl RSS feed http://localhost:3333/ CruiseControl projects and their build statuses en-us 10 passed build 1127 success stuff Tue, 17 Jun 2008 22:12:46 Z http://localhost:3333/builds/passed/1127 http://localhost:3333/builds/passed/1127 passed build 1126 success stuff Tue, 17 Jun 2008 22:12:46 Z http://localhost:3333/builds/passed/1126 http://localhost:3333/builds/passed/1126 EOS