得到NoM​​ethodError:未定义的方法`>'为零:rspec中的NilClass

时间:2017-06-17 12:02:54

标签: rspec capybara rspec-rails

def self.verify_the_order_of_channels(firstwebapp,secondwebapp,firstmobileapp,secondmobileapp)
  expect(firstmobileapp).to be > firstwebapp
  expect(firstmobileapp).to be >  secondwebapp
end

1 个答案:

答案 0 :(得分:1)

firstmobileapp正在nil传递,>未定义nil。你需要查看调用verify_the_order_of_channels的任何内容并查看它为什么通过nil,或者重写期望首先检查nil(当它为零时会出错,你和# 39; ll仍然要弄清楚为什么它被传递为nil)

def self.verify_the_order_of_channels(firstwebapp,secondwebapp,firstmobileapp,secondmobileapp)
  expect(firstmobileapp).not_to be_nil
  expect(firstmobileapp).to be > firstwebapp
  ...
end