seattlerb / zentest

144 stars 72 forks source link

Autotest throws ArgumentError on must_be expectation using jruby #37

Closed xulgos closed 11 years ago

xulgos commented 11 years ago

The simplest way to reproduce:

gem 'minitest'
require 'minitest/autorun'

class A
  def ok?
    true
  end
end

describe A do
  before do
    @a = A.new
  end

  it "should not induce an error" do
    @a.must_be :ok?
  end
end

$ jruby -I.:lib:test test/test_a.rb passes but with autotest it fails with the following error:

$ autotest --verbose No tests matched .autotest /home/***/.rvm/rubies/jruby-1.7.3/bin/jruby -I.:lib:test -rubygems -e "%w[minitest/spec test/test_a.rb].each { |f| require f }" Run options: --seed 35676

Running tests:

E

Finished tests in 0.010000s, 100.0000 tests/s, 0.0000 assertions/s.

1) Error: test_0001_should_not_induce_an_error(A): ArgumentError: wrong number of arguments calling assert_operator (2 for 3) (eval):4:in must_be' /home/***/minispecs/test/test_a.rb:16:intest_0001_should_not_induce_an_error' org/jruby/RubyBasicObject.java:1677:in `send'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

MRI works as expected in both cases.

jruby 1.7.3 ZenTest 4.9.0 rubygems 2.0 Minitest 4.6.2

zenspider commented 11 years ago

Interesting problem!

Unfortunately, it really has little to do with autotest itself, as autotest just runs stuff. I can reproduce this issue by setting up your file structure and running the command by hand:

% ruby19 -I.:lib:test -rubygems -e "%w[minitest/spec test/test_a.rb].each { |f| require f }"
Run options: --seed 43313

# Running tests:

E

Finished tests in 0.000437s, 2288.3295 tests/s, 0.0000 assertions/s.

  1) Error:
test_0001_should_not_induce_an_error(A):
ArgumentError: wrong number of arguments (2 for 3)
    (eval):4:in `must_be'
    /Users/ryan/Work/p4/zss/src/minitest/dev/x/test/test_a.rb:16:in `block (2 levels) in <top (required)>'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

Things of note: This requires ruby 1.9 or some other ruby distro that bundles minitest as a gem. I got a slightly different error than you did. Not sure why, but I doubt that matters all that much.

I get a clean test run when I add a gem activation:

ruby19 -I.:lib:test -rubygems -e "gem 'minitest'; %w[minitest/spec test/test_a.rb].each { |f| require f }"

Gem activation is automatically attempted by simply requiring minitest/autorun instead of minitest/spec. Change that and you should be good.

xulgos commented 11 years ago

Yup, changing from spec to autorun did the trick. I'm using jruby as my default that's why you get a different error.

Thanks, sadly the solution wasn't so interesting ;)

zenspider commented 11 years ago

Uninteresting solutions are awesome. :)

On Mar 2, 2013, at 14:47, Juan Sanchez notifications@github.com wrote:

Yup, changing from spec to autorun did the trick. I'm using jruby as my default that's why you get a different error.

Thanks, sadly the solution wasn't so interesting ;)

— Reply to this email directly or view it on GitHub.