开发者

how to tell autotest to correctly track changes in app source?

I want to get autotest to run Steak acceptance tests whenever one of my rails app's relevant files is changed. After studying Rspec's and Cucumber's own autotest configs, I'm trying the following mappings:


Autotest.add_hook :initialize do |at|
  at.add_mapping(%r%^spec/acceptance/.*_spec.rb$%, true) { |filename, _|
    filename
  }

at.add_mapping(%r%^app/(models|controllers|helpers|lib)/.rb$%) { at.files_matching %r%^s开发者_运维技巧pec/acceptance/._spec.rb$% }

at.add_mapping(%r%^app/views/(.*)/.rb$%) { at.files_matching %r%^spec/acceptance/._spec.rb$% } end

the first one works: whenever a Steak spec is changed, it gets run again.

but the second and third don't. changing any source files under the /app subdirectories just gets ignored.

what's the correct way to get these mappings to work?

thanks Oliver


I just changed my .autotest file to add:

Autotest.add_hook :initialize do |at|
  at.add_mapping(%r%^spec/acceptance/.*_spec.rb$%, true) { |filename, _|
    filename
  }

  at.add_mapping(%r%^app/(models|controllers|helpers|lib)/.*rb$%, true) {
    at.files_matching %r%^spec/acceptance/.*_spec.rb$%
  }

  at.add_mapping(%r%^app/views/(.*)$%, true) {
    at.files_matching %r%^spec/acceptance/.*_spec.rb$%
  }
end

And this is working but I don't know the collateral effects of invoking acceptance tests before others (the true flag on add_mapping)


For RSpec 1.3:

I had to use the :post_initialize hook because the built-in RSpec support starts by clearing all existing mappings. So it was clearing these out and then adding the default RSpec mappings. But using the :post_initialize hook (instead of :initialize on the first line) fixed it.

I also had to put all this in autotest/discover.rb instead of .autotest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜