55502f40dc8b7c769880b10874abc9d0

The puts doesn't happen until the end of the loop?

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 !

F9a9ba6663645458aa8630157ed5e71e

Ants

January 11, 2012, January 11, 2012 10:40, permalink

No rating. Login to rate!

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

Your refactoring





Format Copy from initial code

or Cancel