Forum: Ruby minitest/spec: must_include backwards?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bc368ef524130e8d0deb386de961e24a?d=identicon&s=25 Suraj Kurapati (snk)
on 2009-01-20 10:44
Hello,

In minitest/spec (version 1.3.0), the must_include assertion is
backwards:

  require 'rubygems'
  require 'minitest/spec'
  MiniTest::Unit.autorun

  describe 'foo' do
    it 'bar' do
      5.must_include [5]   # <== passes
      [5].must_include 5   # <== fails
    end
  end

I want to write:

  list.must_include(item)

not:

  item.must_include(list)

Is this a known bug/feature?

Thanks for your consideration.
Bc368ef524130e8d0deb386de961e24a?d=identicon&s=25 Suraj Kurapati (snk)
on 2009-01-21 01:13
Suraj Kurapati wrote:
> In minitest/spec (version 1.3.0),
> the must_include assertion is backwards:
>
>   require 'rubygems'
>   require 'minitest/spec'
>   MiniTest::Unit.autorun
>
>   describe 'foo' do
>     it 'bar' do
>       5.must_include [5]   # <== passes
>       [5].must_include 5   # <== fails
>     end
>   end

minitest 1.3.1 fixes this problem and both assertions pass.
This topic is locked and can not be replied to.