2010-01-22 07:38:23 +00:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
|
|
|
|
|
|
class ConfigTest < Test::Unit::TestCase
|
2010-02-02 06:14:40 +00:00
|
|
|
context "accessing configuration" do
|
2010-01-24 07:38:31 +00:00
|
|
|
setup do
|
2010-02-02 06:14:40 +00:00
|
|
|
Hobo::Config.run { |config| }
|
|
|
|
Hobo::Config.execute!
|
2010-01-24 07:38:31 +00:00
|
|
|
end
|
|
|
|
|
2010-02-02 06:14:40 +00:00
|
|
|
should "forward config to the class method" do
|
|
|
|
assert_equal Hobo.config, Hobo::Config.config
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "initializing" do
|
|
|
|
teardown do
|
|
|
|
Hobo::Config.instance_variable_set(:@config_runners, nil)
|
|
|
|
Hobo::Config.instance_variable_set(:@config, nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
should "not run the blocks right away" do
|
|
|
|
obj = mock("obj")
|
|
|
|
obj.expects(:foo).never
|
|
|
|
Hobo::Config.run { |config| obj.foo }
|
|
|
|
Hobo::Config.run { |config| obj.foo }
|
|
|
|
Hobo::Config.run { |config| obj.foo }
|
2010-01-24 08:09:15 +00:00
|
|
|
end
|
|
|
|
|
2010-02-02 06:14:40 +00:00
|
|
|
should "run the blocks when execute! is ran" do
|
|
|
|
obj = mock("obj")
|
|
|
|
obj.expects(:foo).times(2)
|
|
|
|
Hobo::Config.run { |config| obj.foo }
|
|
|
|
Hobo::Config.run { |config| obj.foo }
|
|
|
|
Hobo::Config.execute!
|
2010-01-24 08:09:15 +00:00
|
|
|
end
|
2010-01-30 06:03:07 +00:00
|
|
|
|
2010-02-02 06:14:40 +00:00
|
|
|
should "run the blocks with the same config object" do
|
|
|
|
config = mock("config")
|
|
|
|
config.expects(:foo).twice
|
|
|
|
Hobo::Config.stubs(:config).returns(config)
|
|
|
|
Hobo::Config.run { |config| config.foo }
|
|
|
|
Hobo::Config.run { |config| config.foo }
|
|
|
|
Hobo::Config.execute!
|
2010-01-30 06:03:07 +00:00
|
|
|
end
|
2010-01-22 07:38:23 +00:00
|
|
|
end
|
|
|
|
end
|