public
Last active

  • Download Gist
README.md
Markdown

Hey Mike,

I wanted to write out a full reply rather than continue a back-and-forth Twitter conversation. I don't want to be "that guy" that publicly does a "drive-by-shit-on" regarding an open-source project. I realize how much time and effort it takes to keep a project like minitest-rails running!

I think my problem with minitest-rails is part philosophical, part practical. Practically, it was a bitch to get working. That's weird to me. I figured the point of minitest-rails would be to just drop it into my Rails project's gemfile and minitest should "just work". But after about 3 hours of trying, it just wouldn't. I ended up writing my own helpers to get minitest working with Rails, and it ended up being a) simpler than I expected, and b) much clearer than what minitest-rails was doing. I'm sure I maybe just missed a few details here and there with minitest-rails that prevented my tests from working, but I'll attach the very minimal code that was required to get minitest working. My question is - why can't minitest rails just do that, add some generators, and let me get on with my life?

Philosophically, I do find it strange that the base minitest-rails class inherits from the Spec DSL rather than the base Minitest class. I couldn't get non-spec-syntax tests working, I figured it was because of this inheritance. Maybe I was wrong, but when I dove into the Minitest-rails source and saw that inheritance, I just figured non-Spec-syntax tests were not supported.

Also philosophically, the whole reason I'm switching to minitest in the first place was because I was frustrated with how much Rspec was "doing for me". As a testimonial in the minitest README says, "Rspec is a testing DSL, minitest is just ruby". I wish that kind of philosophy was evident in minitest-rails, but I just didn't feel like it is.

Anyway, those are my limited impressions from futzing with minitest-rails for 3 hours. I've attached the code I used to get minitest working for me without minitest-rails as a reference. At the end of the day, maybe this is just a documentation problem. An example Rails project with some minitest-rails examples would have been very helpful.

minitest.rake
Ruby
1 2 3 4 5 6 7 8
require "rake/testtask"
 
Rake::TestTask.new(:test => "db:test:prepare") do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
end
 
task :default => :test
minitest_helper.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
Dir[Rails.root.join("test/support/**/*.rb")].each {|f| require f}
 
require 'minitest/autorun'
require 'capybara/rails'
 
class IntegrationTest < MiniTest::Unit::TestCase
include Rails.application.routes.url_helpers
include Capybara::DSL
end
test_something.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
require "minitest_helper"
 
class ExampleTest < MiniTest::Unit::TestCase
 
def setup
@string = String.new
end
 
def test_no_method
assert_raises(NoMethodError){ @string.method_that_doesnt_exist }
end
 
end

I figured the point of minitest-rails would be to just drop it into my Rails project's gemfile and minitest should "just work". But after about 3 hours of trying, it just wouldn't.

I'm sorry you had problems. The point of minitest-rails is that it should "just work". It shouldn't take longer than 5 minutes to get set up, and certainly not 3 hours. What issues did you have? I'm happy to remote pair with you to see what issues you are having and to get it working. Follow and DM me on twitter and we can get something scheduled.

I ended up writing my own helpers to get minitest working with Rails, and it ended up being a) simpler than I expected, and b) much clearer than what minitest-rails was doing.

Yeah, there are several tutorials showing how to get minitest working with rails, even a railscast, but you don't get all the rails testing infrastructure with that approach.

My question is - why can't minitest rails just do that, add some generators, and let me get on with my life?

It totally should. I'd love to know what problems you had so we can make it better.

Philosophically, I do find it strange that the base minitest-rails class inherits from the Spec DSL rather than the base Minitest class.

MiniTest::Spec inherits from MiniTest::Unit::TestCase, so in a sense it does. The reason it inherits directly from MiniTest::Spec is because this is what the tests inherit from in Rails 4.

I just figured non-Spec-syntax tests were not supported.

Well, minitest includes a spec DSL, so supporting minitest means supporting its spec DSL. ¯\(ツ)

Also philosophically, the whole reason I'm switching to minitest in the first place was because I was frustrated with how much Rspec was "doing for me". As a testimonial in the minitest README says, "Rspec is a testing DSL, minitest is just ruby". I wish that kind of philosophy was evident in minitest-rails, but I just didn't feel like it is.

Much of that is about the implementation of RSpec vs. minitest. But even so, the classical test case approach still works. minitest-rails generates classical tests by default, so I'm not sure where you are seeing a conflict.

An example Rails project with some minitest-rails examples would have been very helpful.

Sure. Check out pairwithme. We have a mailing list too, which would be helpful for asking questions.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.