0
votes

I just created a mountable engine. The test directory looks somewhat like this:

engine_name
 -test
  - dummy
  - test_helper.rb
  - models
    -engine_name
      -- user_test.rb
  etc
  1. I attempted to call 'rspec' -> didn't work. Error message stated it couldn't find the folder 'spec'
  2. I then called 'rspec test' -> it found the directory, but didn't find the test.
  3. Found that rspec looks for *_spec.rb files, so I renamed user_test.rb to user_spec.rb
  4. rspec then found the file, but it said it couldn't find test_helper.rb (since that was required by user_spec.rb).

I have a feeling that this engine's test directory is not designed for rspec. What's the best way to test an engine?

Thanks!

1

1 Answers

0
votes

Since you are using rspec, you should use the directory spec instead of test.

The test directory is the default for test unit.

If you run rspec and you have a spec directory it will grab the tests from there.

You need a right spec_helper.rb (test_helper.rb is for test unit). You can see the example of spec_helper.rb in the template from rspec-rails repository.

Then, you should require the spec_helper in the user_spec.rb and just run rspec in the terminal.