Permalink
Browse files

add support for login to config

  • Loading branch information...
1 parent b8cb9c5 commit 2b144ee10fa81004d6d11aa8cd1b6f36239d4fcf @jamesgolick committed May 1, 2009
Showing with 19 additions and 0 deletions.
  1. +9 −0 lib/trample/configuration.rb
  2. +10 −0 test/configuration_test.rb
@@ -25,6 +25,15 @@ def post(url, params = nil, &block)
@pages << Page.new(:post, url, params || block)
end
+ def login
+ if block_given?
+ yield
+ @login = pages.pop
+ end
+
+ @login
+ end
+
def ==(other)
other.is_a?(Configuration) &&
other.pages == pages &&
View
@@ -10,6 +10,11 @@ class ConfigurationTest < Test::Unit::TestCase
get "http://google.com/"
post "http://google.com/", {:q => "something"}
post "http://google.com/", &@params_proc
+ login do
+ post "http://google.com/login" do
+ { :q => "whatever" }
+ end
+ end
end
end
@@ -35,6 +40,11 @@ class ConfigurationTest < Test::Unit::TestCase
assert_equal expected, @config.pages[2]
end
+ should "support a login parameter which contains a page to hit with params" do
+ assert_equal "http://google.com/login", @config.login.url
+ assert_equal({:q => "whatever"}, @config.login.parameters)
+ end
+
should "be equal if all the objects are the same" do
identical_config = Trample::Configuration.new do
concurrency 2

0 comments on commit 2b144ee

Please sign in to comment.