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 statusesen-us10failed build 1126 failedstuffTue, 17 Jun 2008 22:12:46 Zhttp://localhost:3333/builds/failed/1126
http://localhost:3333/builds/failed/1126
passed build 1126 successstuffTue, 17 Jun 2008 22:12:46 Zhttp://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 statusesen-us10my_project build 1126.1 failedstuffTue, 17 Jun 2008 22:12:46 Zhttp://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 statusesen-us10passed build 1127 successstuffTue, 17 Jun 2008 22:12:46 Zhttp://localhost:3333/builds/passed/1127
http://localhost:3333/builds/passed/1127
passed build 1126 successstuffTue, 17 Jun 2008 22:12:46 Zhttp://localhost:3333/builds/passed/1126
http://localhost:3333/builds/passed/1126
EOS