8

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.

user464839
  • 81
  • 3

3 Answers3

3

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.

sunaku
  • 2,156
  • 19
  • 10
james2m
  • 1,562
  • 12
  • 15
  • 1
    Also [shoulda-context](https://github.com/thoughtbot/shoulda-context#readme) works *beautifully* with Rails' standard Test::Unit infrastructure. You don't have to change your code at all! – sunaku Feb 09 '12 at 04:11
2

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

Seth Bro
  • 2,537
  • 3
  • 19
  • 15
  • it seems posterous.com is no longer there... do you know if the article is available elsewhere? – Pablo Marambio Jun 13 '13 at 14:41
  • 1
    Can't find it offhand, Pablo, but that article is out of date by now anyway. Minitest with Rails has come along way. I'd check out this [SO question on Minitest](http://stackoverflow.com/questions/7628654/using-minitest-in-rails/9221625#9221625), & the excellent [minitest-rails gem](https://github.com/blowmage/minitest-rails) – Seth Bro Jun 14 '13 at 14:45
1

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

Szymon Jeż
  • 8,273
  • 4
  • 42
  • 60