![]() G.fixture_replacement :factory_girl, :dir => 'spec/factories' This code requires all the gems you need for writing your specs, loads the dummy application, and configures RSpec.įinally, add this config to your engine file (lives at lib/my_engine/engine.rb): module MyEngine Puts 'You must `gem install bundler` and `bundle install` to run rake tasks'ĪPP_RAKEFILE = File.expand_path("./spec/dummy/Rakefile", _FILE_)ĭir.each Ĭonfig.infer_base_class_for_anonymous_controllers = false ![]() Modify Rakefile to look like this: #!/usr/bin/env rake S.add_development_dependency 'factory_girl_rails'Īdd this line to your gemspec file: s.test_files = Dir This is a good discussion of why you'd choose mountable or full engines.Īdd these lines to the gemspec file: s.add_development_dependency 'rspec-rails' Run rails plugin new ENGINE_NAME -dummy-path=spec/dummy -skip-test-unit -full or rails plugin new ENGINE_NAME -dummy-path=spec/dummy -skip-test-unit -mountable.Here's a few steps to get your new engine up and running with these gems in no time: We really like using RSpec, Capybara, and FactoryGirl to test our Rails applications, and we like to use them to test our engines too. We've found it's a good way to organize and share reusable code across a number of applications. We've developed a few engines that we've released publicly, and even more that we use privately on applications. Recently, we've been doing a lot more with Rails engines. UPDATED: I've updated the instructions based on feedback in the comments suggesting the use of the -dummy-path=spec/dummy -skip-test-unit options on the rails plugin new command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |