Skip to content

Commit

Permalink
quick refacotring
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgolick committed Apr 30, 2009
1 parent 5a40d78 commit 9552ae9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/trample/session.rb
Expand Up @@ -14,21 +14,24 @@ def initialize(config)
def trample
@config.iterations.times do
@config.pages.each do |p|
request p
hit p
end
end
end

protected
def hit(page)
response_times << request(page)
# this is ugly, but it's the only way that I could get the test to pass
# because rr keeps a reference to the arguments, not a copy. ah well.
@cookies = cookies.merge(last_response.cookies)
logger.info "#{page.request_method.to_s.upcase} #{page.url} #{response_times.last}s"
end

def request(page)
length = time do
time do
@last_response = RestClient.send(page.request_method, page.url, :cookies => cookies)
# this is ugly, but it's the only way that I could get the test to pass
# because rr keeps a reference to the arguments, not a copy. ah well.
end
@cookies = cookies.merge(last_response.cookies)
response_times << length
logger.info "#{page.request_method.to_s.upcase} #{page.url} #{length}s"
end
end
end

0 comments on commit 9552ae9

Please sign in to comment.