Skip to content

Loading…

RSpec 2.6 adds NilClass#empty? and it returns false #376

Closed
nov opened this Issue · 2 comments

2 participants

@nov

It seems RSpec::Core::World::Describable adds it.

describe NilClass do
  subject { nil }
  it { should_not respond_to :empty? }
end

This changes the behavior of this code.

def some_method(variable)
  if variable.respond_to?(:empty?)
    do_something
  elsif variable.nil?
    do_something
  end
end
@dchelimsky
RSpec member

Thanks for pointing me directly to the problem.

@nov

I love your quickest fix ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.