Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
add rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
lidaobing committed Nov 24, 2011
1 parent 026cb30 commit 7ac96e6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
*.gem
.bundle
Gemfile.lock
pkg/*
*.swp
test
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--color --format documentation
4 changes: 2 additions & 2 deletions lib/capistrano/recipes/deploy/scm/jenkins.rb
Expand Up @@ -23,13 +23,13 @@ def checkout(revision, destination)
end

private
def get_last_successful_build(message = nil)
def last_successful_build(message = nil)
message = rss_all if message.nil?
doc = REXML::Document.new(message).root
REXML::XPath.each(doc,"./entry/title") do |title|
title = title.text
if title.end_with? '(back to normal)' or title.end_with? '(stable)':
return /#(\d+) \([^(]+$/.match(a)[1]
return /#(\d+) \([^(]+$/.match(title)[1]
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions spec/capistrano/recipes/deploy/scm/jenkins_spec.rb
@@ -0,0 +1,18 @@
require 'spec_helper'
require 'capistrano/recipes/deploy/scm/jenkins'

module Capistrano::Deploy::SCM
describe Jenkins do
before :each do
@jenkins = Jenkins.new
end

context "last_successful_build" do
it "should support back to normal" do
msg = %Q{<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>estore-nginx all builds</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/" rel="alternate"/><updated>2011-11-24T07:11:06Z</updated><author><name>Jenkins Server</name></author><id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id><entry><title>estore-nginx #2 (back to normal)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/2/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:estore-nginx:2011-11-24_15-11-06</id><published>2011-11-24T07:11:06Z</published><updated>2011-11-24T07:11:06Z</updated></entry><entry><title>estore-nginx #1 (broken for a long time)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/1/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:estore-nginx:2011-11-24_15-09-18</id><published>2011-11-24T07:09:18Z</published><updated>2011-11-24T07:09:18Z</updated></entry></feed>}
@jenkins.send(:last_successful_build, msg).should == '2'
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
@@ -0,0 +1 @@
require 'rspec'

0 comments on commit 7ac96e6

Please sign in to comment.