Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve config syntax a little

  • Loading branch information...
commit a77eeaa4ec82753574f4e381e3b90f87c3dd2d82 1 parent c169fb9
@jamesgolick authored
View
4 lib/trample/configuration.rb
@@ -2,9 +2,9 @@ module Trample
class Configuration
attr_reader :pages
- def initialize
+ def initialize(&block)
@pages = []
- yield self
+ instance_eval(&block)
end
def concurrency(*value)
View
24 test/configuration_test.rb
@@ -3,10 +3,10 @@
class ConfigurationTest < Test::Unit::TestCase
context "Configuration trample" do
setup do
- @config = Trample::Configuration.new do |t|
- t.concurrency 2
- t.iterations 1
- t.get "http://google.com/"
+ @config = Trample::Configuration.new do
+ concurrency 2
+ iterations 1
+ get "http://google.com/"
end
end
@@ -24,19 +24,19 @@ class ConfigurationTest < Test::Unit::TestCase
end
should "be equal if all the objects are the same" do
- identical_config = Trample::Configuration.new do |t|
- t.concurrency 2
- t.iterations 1
- t.get "http://google.com/"
+ identical_config = Trample::Configuration.new do
+ concurrency 2
+ iterations 1
+ get "http://google.com/"
end
assert_equal identical_config, @config
end
should "not be equal if any of the objects are different" do
- non_identical_config = Trample::Configuration.new do |t|
- t.concurrency 3
- t.iterations 1
- t.get "http://google.com/"
+ non_identical_config = Trample::Configuration.new do
+ concurrency 3
+ iterations 1
+ get "http://google.com/"
end
assert_not_equal non_identical_config, @config
end
View
6 test/fixtures/basic_config.rb
@@ -1,5 +1,5 @@
Trample.configure do |t|
- t.concurrency 2
- t.iterations 1
- t.get "http://google.com"
+ concurrency 2
+ iterations 1
+ get "http://google.com"
end
View
14 test/session_test.rb
@@ -2,10 +2,10 @@
class SessionTest < Test::Unit::TestCase
def setup
- @config = Trample::Configuration.new do |t|
- t.iterations 2
- t.get("http://google.com/")
- t.get("http://amazon.com/")
+ @config = Trample::Configuration.new do
+ iterations 2
+ get "http://google.com/"
+ get "http://amazon.com/"
end
@session = Trample::Session.new(@config)
end
@@ -43,9 +43,9 @@ def setup
stub(response).cookies { {"xyz" => "abc"} }
end
- @config = Trample::Configuration.new do |t|
- t.iterations 2
- t.get("http://amazon.com/")
+ @config = Trample::Configuration.new do
+ iterations 2
+ get "http://amazon.com/"
end
@session = Trample::Session.new(@config)
Please sign in to comment.
Something went wrong with that request. Please try again.