metaskills / minitest-spec-rails

:bento: Make Rails Use MiniTest::Spec!

Home Page:http://github.com/metaskills/minitest-spec-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to include FactoryGirl?

elsom25 opened this issue · comments

I've attempted to extend MiniTest to include the factory girl methods with little luck. Including in test_helper.rb:

# MiniTest
class MiniTest::Unit::TestCase
  include FactoryGirl::Syntax::Methods
end

# MiniTest::Spec
class MiniTest::Spec
  include FactoryGirl::Syntax::Methods
end

Doesn't allow for direct access to FactoryGirl methods, and not really sure what else to try? Any help would be greatly appreciated.

If you were using vanilla MiniTest, this would work. But when using Rails, you should just do this, in your test_helper.rb. Please let me know if that does not work.

class ActiveSupport::TestCase
  include FactoryGirl::Syntax::Methods
end

Worked perfectly. Thank-you kindly

Great! For anyone else that happens by this issue, just remember that we inject the MiniTest DSL into ActiveSupport. This project is Rails centric and always approach your architecture from the Rails perspective first and you should always win. Cheers!