`rspec` - 比较两个数组的长度 [英] `rspec` - comparing two arrays' lengths against each other
本文介绍了`rspec` - 比较两个数组的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 index
方法中有 2 个数组,我想测试数组长度的相等性但它不起作用(手动测试后数组的长度相等)
Having 2 arrays in index
method, I want to test the equality of the arrays' lengths but it's not working (the lengths of the arrays are equal after testing manually)
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
推荐答案
您似乎不是在向该操作发出请求……也就是说……get :index
在哪里打电话?
Doesn't look like you are making a request to that action... that is.. where is the get :index
call?
这篇关于`rspec` - 比较两个数组的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文