【发布时间】:2011-01-18 23:05:41
【问题描述】:
有没有办法使用 Factory Girl 向 Ruby on Rails 中的测试数据库提交新的更改?
我有以下工厂:
Factory.define :shipping_info do |si|
si.name "Foo Bar"
si.street "12 Candy Lane"
si.country "US"
si.zip "12345"
si.state "IL"
end
我有以下测试:
require File.dirname(__FILE__) + '/../../spec_helper'
describe CgCart::ShippingInfo do
before(:each) do
@order = Factory(:order)
@order.order_line_item = Factory(:order_line_item)
@shipping_info = Factory(:shipping_info)
end
it "order should not be nil" do
@shipping_info.should_not be_nil
end
end
当我运行这个测试时,它通过了。但是,我的测试数据库中没有创建新记录。我需要那里的数据供 Dameon 使用。
有什么建议吗?
【问题讨论】:
标签: ruby-on-rails database unit-testing factory-bot