rspec what is the difference between be nil and be_nil
问题 I am using rspec and for asserts like student.name should be nil student.name should be_nil Both seem to work. is there a difference between using be nil an be_nil ??? 回答1: There is no difference really, except be nil gets defined on the fly, and be_nil has been specifically programmed by rspec. when you say should.be something , rspec tries the following [:==, :<, :<=, :>=, :>, :===].each do |operator| define_method operator do |operand| BeComparedTo.new(operand, operator) end end Whereas,