-->

Has anyone used Minitest::Spec withing a Rails fun

2019-03-27 14:07发布

问题:

The spec library in Minitest is great. I've been able to use it within Rails unit tests no problem. However, Rails functional test inherit from ActionController::TestCase which provides instance variables like @controller in it's setup.

Has anyone been using the Minitest::Spec lib for their Rails functional tests?

If not, I'm considering creating a small library to do just that. I'm not too keen on rspec, and shoulda is starting to shift it's focus to rspec. It would be nice to have something lightweight and built on tools already provided.

回答1:

Here's a simple test_helper rig to run functional & integration tests in Rails using spec syntax. Based on a gist by tenderlove, this excellent article about MiniTest with Capybara, & a lot of tinkering & source-poring.

https://gist.github.com/1607879



回答2:

Thoughtbot have now split shoulda into shoulda_contexts and shoulda_matchers so the worry about a shift to rspec for thoughtbot doesn't mean shoulda contexts are going away. Just being maintained in the community.



回答3:

Maybe try http://metaskills.net/2011/03/26/using-minitest-spec-with-rails/.