【发布时间】:2012-12-12 04:05:53
【问题描述】:
我想在相同的测试中对一些获取请求进行分组,但我得到了不稳定的行为。我有以下两个测试:
test 'index for local seller (same site)' do
seller = FactoryGirl.create :seller, business_site: @open_or.business_site
get :index, nil, {user_id: seller.to_param }
assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}"
end
test 'index for local seller (different site)' do
seller = FactoryGirl.create :seller_local
get :index, nil, {user_id: seller.to_param }
assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}", false
end
我想在一个测试中组合它,但如果我这样做,第二个断言将错误地失败(预计正好 0 个元素匹配“table#order_requests tr#order_request_1000244799”,找到 1.)。我真的不明白为什么?第二个“获取”调用可能无法正确重置某些内容。我寻找“重置”请求的方法但没有成功。
相关:making two requests to the same controller in rails integrations specs
【问题讨论】:
标签: ruby-on-rails functional-testing