features/step_definitions/hudson_steps.rb in hudson-0.2.7 vs features/step_definitions/hudson_steps.rb in hudson-0.3.0.beta.1
- old
+ new
@@ -1,29 +1,29 @@
Given /^I have a Hudson server running$/ do
- unless ENV['HUDSON_PORT']
+ unless @hudson_port
port = 3010
begin
res = Net::HTTP.start("localhost", port) { |http| http.get('/api/json') }
rescue Errno::ECONNREFUSED => e
puts "\n\n\nERROR: To run tests, launch hudson in test mode: 'rake hudson:server:test'\n\n\n"
exit
end
- ENV['HUDSON_PORT'] = port.to_s
- ENV['HUDSON_HOST'] = 'localhost'
+ @hudson_port = port.to_s
+ @hudson_host = 'localhost'
end
end
Given /^the Hudson server has no current jobs$/ do
- if port = ENV['HUDSON_PORT']
+ if port = @hudson_port
require "open-uri"
require "yajl"
- hudson_info = Yajl::Parser.new.parse(open("http://localhost:#{ENV['HUDSON_PORT']}/api/json"))
+ hudson_info = Yajl::Parser.new.parse(open("http://#{@hudson_host}:#{@hudson_port}/api/json"))
hudson_info['jobs'].each do |job|
job_url = job['url']
res = Net::HTTP.start("localhost", port) { |http| http.post("#{job_url}doDelete/api/json", {}) }
end
- hudson_info = Yajl::Parser.new.parse(open("http://localhost:#{ENV['HUDSON_PORT']}/api/json"))
+ hudson_info = Yajl::Parser.new.parse(open("http://#{@hudson_host}:#{@hudson_port}/api/json"))
hudson_info['jobs'].should == []
else
puts "WARNING: Run 'I have a Hudson server running' step first."
end
end