rspec what is the difference between be nil and be_nil

rspec2, ruby-on-rails

Solution

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, when you try `should.be_nil` it just checks

object.nil?

https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/be.rb

Problem

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` ???

Original source