Well, you don’t show the combined test, and you don’t show what the failure is, so it works pretty much in the dark, but to combine these tests I can do something like
test 'index for seller (same site)' do first_seller = FactoryGirl.create :seller, business_site: @open_or.business_site get :index, nil, {user_id: first_seller.to_param } assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}" second_seller = FactoryGirl.create :seller_local get :index, nil, {user_id: second_seller.to_param } assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}", false end
The above assumes that your individual tests pass, and if it is not, I can understand why this will not work (but I do not see very well in the dark)
By the way, tests do not fail by mistake, there is always a reason for a failed test, and usually it is a real failure or a poorly thought out test, since this is an error introduced by the programmer, and not a test error for all!
UPDATE - look in the browser to find out what is actually on the web page when the test fails using save_and_open_page, like railscast http://railscasts.com/episodes/275-how-i-test
The difference between combined tests and individual tests is that the database is cleared between each test, so your first seller will still exist in the database in your combined test, but will not exist in the second test when they are run as separate Tests
source share