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

Closed
nov opened this Issue May 18, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@nov

nov commented May 18, 2011

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

This comment has been minimized.

Show comment
Hide comment
@dchelimsky

dchelimsky May 18, 2011

Member

Thanks for pointing me directly to the problem.

Member

dchelimsky commented May 18, 2011

Thanks for pointing me directly to the problem.

@nov

This comment has been minimized.

Show comment
Hide comment
@nov

nov May 18, 2011

I love your quickest fix ;)

nov commented May 18, 2011

I love your quickest fix ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment