在我的groups.rb工厂……
FactoryGirl.define do factory :group do sequence :name do |n| "Group#{n}" end expiry Date.today + 2.weeks endend
并在我的groups_spec.rb中使用它…
describe "Groups" do describe "GET /groups" do it "an admin user can create a new group" do user = Factory.create(:user,:is_admin => true ) group = Factory.build(:group) visit root_url fill_in "Email",:with => user.email fill_in "Password",:with => user.password click_button "Login" click_link "Groups" click_link "New Group" fill_in "name",:with => group.name # need to change the below to use the Factory eg select Date.new(group.expiry) select "2014",:from => "group_expiry_1i" select "June",:from => "group_expiry_2i" select "1",:from => "group_expiry_3i" click_button "Create Group" page.should have_content("Group was successfully created.") page.should have_content(group.name) end endend
所以你看到这不是一个好的方法来进行测试,因为我没有使用工厂生成的到期.有谁知道如何正确输入表格中的失效日期?
解决方法 这只是在没有在Capybara测试的袖口,但我尝试:select group.expiry.year.to_s,:from => "group_expiry_1i"select Date::MONTHnameS[group.expiry.month],:from => "group_expiry_2i"select group.expiry.date.to_s,:from => "group_expiry_3i"
只要这些值实际存在于下拉列表中,它就应该正确选择它们.
总结以上是内存溢出为你收集整理的ruby-on-rails – 使用工厂女孩和水豚输入日期全部内容,希望文章能够帮你解决ruby-on-rails – 使用工厂女孩和水豚输入日期所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)