0
在index
方法中有2個數組,我想測試數組長度是否相等,但它不工作(手動測試後數組長度相等)在rpec中檢查數組的長度(實例變量)
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
[\ rspec \' - 將兩個數組的長度相互比較]的可能重複(http://stackoverflow.com/questions/38579733/rspec-comparing-two-arrays-lengths-against-each-other ) –