Vra

I have some submodules organized like this:

|-- app
|   |-- models
|   |   |-- foo
|   |   |   |-- foo-1.rb
|   |   |   |-- foo-2.rb
|   |   |   |-- foo-3.rb
|   |   |-- foo.rb

How can I get autotest to notice changes made to foo-*.rb, and then run the appropriate specs?

Was dit nuttig?

Oplossing

You can populate your autotest/discover.rb file with mappings:

Autotest.add_hook :initialize do |at|
  # match the model name (the whole Regex object is in _)
  at.add_mapping(%r%^app/models/(foo)/\w+\.rb$%, true) do |filename, _|
    "spec/models/#{_[1]}_spec.rb"
  end
end

You can find more how to use the mappings and hooks in the API docs.

Ander wenke

Perhaps you should investigate watchr

https://github.com/mynyml/watchr

It's similar to autotest, while being quite a bit more configurable and more easily setup.

Another interesting alternative is guard.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top