When /^I request test urls with headers "([^"]*)" "([^"]*)"$/ do |accept, headers|
header_map = create_header_map_from_string(headers)
test_urls = load_fixture("test-urls1.txt")
test_urls.each_line do |line|
begin
response = get_with_custom_header(line, accept, header_map)
rescue => e
if !e.respond_to?('response')
throw e
end
response = e.response
end
puts "got http #{response.code} for #{line}"
end
end
Refactorings
No refactoring yet !
Ants
January 11, 2012, January 11, 2012 10:40, permalink
I think it's because your second 'end' ended the loop block. I think you meant to use 'ensure', rather than 'end' at that point.
When /^I request test urls with headers "([^"]*)" "([^"]*)"$/ do |accept, headers|
header_map = create_header_map_from_string(headers)
test_urls = load_fixture("test-urls1.txt")
test_urls.each_line do |line|
begin
response = get_with_custom_header(line, accept, header_map)
rescue Exception => e
if !e.respond_to?('response')
throw e
end
response = e.response
ensure
puts "got http #{response.code} for #{line}"
end
end
The puts doesn't happen until the end of the loop?