Skip to content
Browse files

fix last test

  • Loading branch information...
1 parent 74e13cb commit 5a40d7817bb07cf23bbdcef8dad9a75ec842d202 @jamesgolick committed Apr 30, 2009
Showing with 8 additions and 4 deletions.
  1. +3 −3 lib/trample/session.rb
  2. +5 −1 test/session_test.rb
View
6 lib/trample/session.rb
@@ -3,7 +3,7 @@ class Session
include Logging
include Timer
- attr_reader :config, :response_times, :cookies
+ attr_reader :config, :response_times, :cookies, :last_response
def initialize(config)
@config = config
@@ -22,11 +22,11 @@ def trample
protected
def request(page)
length = time do
- response = RestClient.send(page.request_method, page.url, :cookies => cookies)
+ @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.
- @cookies = cookies.merge(response.cookies)
end
+ @cookies = cookies.merge(last_response.cookies)
response_times << length
logger.info "#{page.request_method.to_s.upcase} #{page.url} #{length}s"
end
View
6 test/session_test.rb
@@ -24,10 +24,14 @@ def setup
context "Visiting a page" do
setup do
stub(@session).time { 1.4 }
+ stub(@session).last_response do
+ response = RestClient::Response.new("", stub!)
+ stub(response).cookies { {} }
+ end
@session.trample
end
- should "record the length of tiem it took to visit that page" do
+ should "record the length of time it took to visit that page" do
assert_equal [1.4, 1.4, 1.4, 1.4], @session.response_times
end
end

0 comments on commit 5a40d78

Please sign in to comment.
Something went wrong with that request. Please try again.