2008-12-23 14:03:29 -05:00
|
|
|
require(File.join(File.dirname(__FILE__), 'test_helper'))
|
|
|
|
|
2009-01-02 16:39:24 -05:00
|
|
|
class Proxy < Test::Unit::TestCase
|
2008-12-23 14:03:29 -05:00
|
|
|
|
2009-01-02 16:39:24 -05:00
|
|
|
context "a proxy" do
|
2008-12-23 14:03:29 -05:00
|
|
|
setup do
|
2009-01-02 16:39:24 -05:00
|
|
|
@proxy = Factory::Proxy.new(Class.new)
|
2008-12-23 14:03:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
should "do nothing when asked to set an attribute to a value" do
|
2009-01-02 16:39:24 -05:00
|
|
|
assert_nothing_raised { @proxy.set(:name, 'a name') }
|
2008-12-23 14:03:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
should "return nil when asked for an attribute" do
|
2009-01-02 16:39:24 -05:00
|
|
|
assert_nil @proxy.get(:name)
|
2008-12-23 14:03:29 -05:00
|
|
|
end
|
|
|
|
|
2009-01-02 16:27:58 -05:00
|
|
|
should "call get for a missing method" do
|
2009-01-02 16:39:24 -05:00
|
|
|
@proxy.expects(:get).with(:name).returns("it's a name")
|
|
|
|
assert_equal "it's a name", @proxy.name
|
2009-01-02 16:27:58 -05:00
|
|
|
end
|
|
|
|
|
2008-12-23 14:03:29 -05:00
|
|
|
should "do nothing when asked to associate with another factory" do
|
2009-01-02 16:39:24 -05:00
|
|
|
assert_nothing_raised { @proxy.associate(:owner, :user, {}) }
|
2008-12-23 14:03:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
should "raise an error when asked for the result" do
|
2009-01-02 16:39:24 -05:00
|
|
|
assert_raise(NotImplementedError) { @proxy.result }
|
2008-12-23 14:03:29 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|