Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add block based parameters

  • Loading branch information...
commit 83d53f233f52d2e103f64f3cfae85bf986496697 1 parent 1e2e041
@jamesgolick authored
Showing with 15 additions and 1 deletion.
  1. +5 −1 lib/trample/page.rb
  2. +10 −0 test/page_test.rb
View
6 lib/trample/page.rb
@@ -1,6 +1,6 @@
module Trample
class Page
- attr_reader :request_method, :url, :parameters
+ attr_reader :request_method, :url
def initialize(request_method, url, parameters = {})
@request_method = request_method
@@ -8,6 +8,10 @@ def initialize(request_method, url, parameters = {})
@parameters = parameters
end
+ def parameters
+ @parameters.is_a?(Proc) ? @parameters.call : @parameters
+ end
+
def ==(other)
other.is_a?(Page) &&
other.request_method == request_method &&
View
10 test/page_test.rb
@@ -26,5 +26,15 @@ class PageTest < Test::Unit::TestCase
assert_not_equal Trample::Page.new(:get, "http://google.com"), Trample::Page.new(:get, "http://google.com/asdf")
end
end
+
+ context "Block-based request parameters" do
+ setup do
+ @page = Trample::Page.new(:get, "http://google.com/", lambda { { :username => "joetheuser" } })
+ end
+
+ should "be resolved when the page is asked for its parameters" do
+ assert_equal({:username => "joetheuser"}, @page.parameters)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.