在index
方法中有2个数组,我想测试数组的相等性。长度,但它不起作用(手动测试后阵列的长度相等)
def index
@countries = get_countries()
@capitals = get_capitals()
end
Rspec文件:
describe CountriesController do
describe 'index' do
it 'countries.length == capitals.length' do
expect(assigns(countries.length)).to eq (assigns(capitals.length))
end
end
end
答案 0 :(得分:1)
看起来你没有向该行动提出请求......那就是get :index
电话在哪里?
答案 1 :(得分:0)
应该是这样的:
describe CountriesController do
describe 'index' do
it 'countries.length == capitals.length' do
get :index
expect(assigns(:countries).length).to eq assigns(:capitals).length
end
end
end