1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/test/strategy_test.rb
2009-01-02 16:39:24 -05:00

33 lines
869 B
Ruby

require(File.join(File.dirname(__FILE__), 'test_helper'))
class Proxy < Test::Unit::TestCase
context "a proxy" do
setup do
@proxy = Factory::Proxy.new(Class.new)
end
should "do nothing when asked to set an attribute to a value" do
assert_nothing_raised { @proxy.set(:name, 'a name') }
end
should "return nil when asked for an attribute" do
assert_nil @proxy.get(:name)
end
should "call get for a missing method" do
@proxy.expects(:get).with(:name).returns("it's a name")
assert_equal "it's a name", @proxy.name
end
should "do nothing when asked to associate with another factory" do
assert_nothing_raised { @proxy.associate(:owner, :user, {}) }
end
should "raise an error when asked for the result" do
assert_raise(NotImplementedError) { @proxy.result }
end
end
end