我有两个模型,Poll和PollItem。我创建了这个模型工厂的测试:
我添加了下一个工厂:
工厂/ polls.rb
public CustonControl()
{
Loaded += HookToCtrlC;
}
private void HookToCtrlC(object sender, EventArgs e)
{
var parentWindow = Window.GetWindow(this);
parentWindow.KeyDown += CopySelectedTextToClipboard;
}
private void CopyMarkedNucleotidesToClipboard(object sender, KeyEventArgs e)
{
Clipboard.SetText("Hello World!");
}
工厂/ poll_items.rb :
FactoryGirl.define do
factory :poll do
question "What programming language are you using?"
results_hidden 1
from_date "2015-06-25 18:13:18"
to_date "2015-07-25 18:13:18"
trait :poll_item1 do
association :poll_item,
answer: "C#",
votes_count: "1"
end
trait :poll_item2 do
association :poll_item,
answer: "Ruby",
votes_count: "2"
end
end
end
我运行我的规范测试:
FactoryGirl.define do
factory :poll_item do
answer "MyString"
votes_count "1"
end
end
运行i test时,显示错误 - NoMethodError:未定义方法`votes_count ='表示#./spec/models/poll_spec.rb:5:in