Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to test Rails 3 Engines with Cucumber & Rspec?
    primarykey
    data
    text
    <p>I apologize if this question is slightly subjective... I am trying to figure out the best way to test Rails 3 Engines with Cucumber &amp; Rspec. In order to test the engine a rails 3 app is necessary. Here is what I am currently doing:</p> <ol> <li><p>Add a rails test app to the root of the gem (myengine) by running: <code>rails new /myengine/rails_app</code></p></li> <li><p>Add Cucumber to <code>/myengine/rails_app/features</code> as you would in a normal Rails app</p></li> <li><p>Require the Rails Engine Gem (using <code>:path=&gt;"/myengine"</code>) in <code>/myengine/rails_app/Gemfile</code></p></li> <li><p>Add spec to the root directory of the gem: <code>/myengine/spec</code></p></li> <li><p>Include the fixtures in <code>/myengine/spec/fixtures</code> and I add the following to my cuc env.rb:</p></li> </ol> <p>env.rb:</p> <pre><code>Fixtures.reset_cache fixtures_folder = File.join(Rails.root, 'spec', 'fixtures') fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') } Fixtures.create_fixtures(fixtures_folder, fixtures) </code></pre> <p>Do you see any problems with setting it up like this? The tests run fine, but I am a bit hesitant to put the features inside the test rails app. I originally tried putting the features in the root of the gem and I created the test rails app inside <code>features/support</code>, but for some reason my engine would not initialize when I ran the tests, even though I could see the app loading everything else when cuc ran.</p> <p>If anyone is working with Rails Engines and is using cuc and rspec for testing, I would be interested to hear your setup. </p> <p>*<strong>*UPDATE</strong><br> I changed my setup a bit since I wrote this question. I decided to get rid of the spec directory under the root of the engine. Now I just create a rails app named "test_app" and setup cuc and rspec inside that app like I would normally do in a rails app. Then I include the gem like I did in step #3 above. Since the engine is a sub-app, I guess its just best to test it like it was a normal rails app. I am still interested in hearing if anyone has a different setup.</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.
 

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