0

I got a strange problem with minitest and capybara.

I am using rails 3.2.8 and test with minitest/capybara/poltergeist. Until now every went fine. I always could test my javascript stuff.

For a new project I downloaded rails 4 to get into it a little bit. And since minitest will be the testing framework I thought it would be easy. It was not. Truth be told, I am not a hero when it comes to setting up all the stuff. I just follow Ryan Bates. After a lot of adding and removing and updating a lot of gems I decided it wasn't worth to continue to use Rails 4. I had so many issues with getting into the groove with my integration tests. All the stuff I knew did not work as expected. The axe fell when almost everything worked until I wanted to test a javascript thing. I got this error:

.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/minitest-4.6.1/lib/minitest/spec.rb:190:in `it': wrong number of arguments (2 for 1) (ArgumentError)

because of this

describe "blabla" do
  it "does not do what i want it to do", js: true do
    pending
  end
end

It will not accept the js: true argument. Funny thing is that the describe block will accept the js: true argument.

When I went back to Rails 3.2.8, because I thought it was a Rails 4 thing, this baby followed me right into a new testsuite. I tried hard to find an answer on Google but I can't find any. My other rails 3.2.8 projects still test fine, no complains about the javascript argument. But with the new apps: no javascript testing.

I am at a loss here. I have no idea where this is coming from. Since my other 3.2.8 apps still work fine, it has probably something to do with renewed gem versions? Has anybody seen this error message? I checked the complaining minitest/spec.rb file from the error message, line 190 for several minitest versions and nothing changed in the it-method.

Please let me know if you want to see stuff (Gemfile? test_helper.rb?) if you have any clue about what might be wrong. Thanks in advance!

Casper

1 Answers1

1

Minitest's spec DSL does not accept a second parameter for the it blocks. The minitest-metadata gem adds support for the second argument, and the example shows how to configure Capybara to use it. Perhaps your existing projects use minitest-metadata and configure Capybara with it, and your new projects don't?

blowmage
  • 8,854
  • 2
  • 35
  • 40
  • Thank you. I did not saw this reply until now. Never noticed it. You are completely right and thanks for letting me understand this a bit better. The new project uses Rails 4 which uses minitest by default. Therefore I didn't thought it was necessary to include the metadata gem. – Casper Kaandorp Mar 15 '13 at 12:43
  • FWIW, you can use minitest-rails and minitest-rails-capybara in Rails 4. They will enable the minitest spec DSL *and* the Capybara DSL in Rails 4, including metadata support in the Capybara tests. – blowmage Mar 20 '13 at 16:58