Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am using RSpec with a Rails engine without issues.</p> <p>I created my plugin using the following switches: -T --full --dummy-path=spec/dummy.</p> <ul> <li><code>-T</code> excludes test/unit</li> <li><code>--full</code> indicates that the plugin is an engine</li> <li><code>--dummy-path</code> is simply so that we don't get a test directory (the default is test/dummy).</li> </ul> <p>From there I used the spec_helper from the "start your engines" article:</p> <pre><code># Configure Rails Envinronment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) require 'rspec/rails' ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../') # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f } RSpec.configure do |config| config.use_transactional_fixtures = true end </code></pre> <p>For the generators. I add a config.generators block to my engine.rb file like so:</p> <pre><code>module MyEngine class Engine &lt; Rails::Engine config.generators do |g| g.test_framework :rspec, :view_specs =&gt; false end end end </code></pre> <p>With that, I'm able to get rspec tests when running a generator like the model generator.</p> <p>As for the DB, is your database.yml file set up correctly? Did you load the test environment, e.g. <code>rake db:test:clone</code> or <code>rake db:migrate RAILS_ENV=test</code>? My guess is that RSpec can't see your tables because there isn't a test database set up.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload