2

We create rails 3.2.9 engine with the command below:

rails plugin new my_eng --mountable --dummy-path=spec/dummy

in my_eng.gemspec, rspec was added:

s.add_development_dependency "rspec-rails", ">= 2.0.0"

Run bundle install. Then in engine's root directory:

rails g rspec:install

A spec_helper.rb file is created under spec/.

The problem is that when a model or controller is created,ex, rails g model my_model..., under spec/, there is no models directory and my_model_spec.rb were created. We tried to run rails g rspec:install under spec/dummy/ and the problem remains. What's wrong with our code? Thanks for the help.

1

1 Answer 1

3

You gotta insert in config/application.rb something like:

config.generators do |g|
  g.template_engine :erb
  g.test_framework  :rspec, :fixture => true, :views => false
  g.integration_tool :rspec, :fixture => true, :views => true
  g.fixture_replacement :factory_girl, :dir => "spec/support/factories" 
end
Sign up to request clarification or add additional context in comments.

4 Comments

In engine.rb, we use the exact same code from Brian's: config.generators do |g| g.test_framework :rspec, :view_specs => false end. Among 10 engines created, there is one rspec working. Just tried the following and it worked: config.generators.integration_tool :rspec config.generators.test_framework :rspec. This code is basically doing the same as what it is in RodrigoOliveira or Brian's. But not sure why the code with do loop was not working every time as it should be.
What does the :views => true or false mean? With the code above, is factory girl created along with a rails generator?
It mean that view's specs will not be created.
Is it erb by default (g.template_engine :erb)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.