Skip to content

Commit

Permalink
improve config syntax a little
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgolick committed May 1, 2009
1 parent c169fb9 commit a77eeaa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/trample/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/basic_config.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions test/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a77eeaa

Please sign in to comment.