Rails engine test / dummy with Spork, Guard, RSpec?

I have a Rails stone that I am testing with RSpec. My gem code is in lib / my_gem, and there is a test application that Rails generates for me when I created the stone, in the test / dummy folder. I have my specifications in test / dummy / spec / models / task_spec.rb. I can fulfill these specifications with the rspec command.

Now I wanted to use Spork and Guard for testing. I ran RailsCasts http://railscasts.com/episodes/285-spork to install spork in my test / dummy application. It works, but I have 2 questions:

  • How to make spork reload my lib / my_gem / * files? I tried putting paths like .. /../ lib / my_gem / ... into my Guardfile, but it doesn’t look / reload files.
  • For some reason, rspec is ignoring my parameters from spec_helper, for example the line "config.filter_run: focus => true". I put them in Spork.prefork correctly. This option works when I start rspec manually using rspec spec / models / task_spec.rb, but it is ignored when I use guard / spork.
+3
source share
3 answers

- . , test/dummy. , https://github.com/mrbrdo/has_moderated , Guardfile ( test/dummy), Rakefile ( ) spec_helper.rb( spec/ test/dummy/spec). , - .

+1

config.cache_classes true. spork, , . ./config/environments/test.rb.

config.filter_run :focus => true RSpec: https://www.relishapp.com/rspec/rspec-core/v/2-4/docs/command-line/tag-option

+1

Spring now has documentation on how to use it when developing the Rails Engine. https://github.com/rails/spring#application-root

Just indicate where to find the root of the test application:

Spring.application_root = './test/dummy'
0
source

All Articles