开发者

How would one go about populating the database of a rails app based on the contents of another repository within the rails application's repository?

So my current situation is this:

I have a rails app called commander. Within this repository is another reposity (git submodule to be specific) that has cucumber/capybara acceptance tests for a different web application. The ultimate goal of commander is to grep through this acceptance tests repository and pull out all features, scenarios, background, tags etc and put them up into a nice, pretty GUI. I'd like to be able to list the features, click on them, see the scenarios in a feature, see the tags in a scenario, etc. So far I've got a scaffold set up for feature, scenario, etc etc in the rails database.

The question I'm wondering i开发者_Python百科s: What's the best approach to populating this database? If there's more content added to the acceptance test repository, the whole grep process will need to be fired off again and the database will need to be updated with any new features/scenarios/etc that may have been added to the acceptance test repository. And if the index action of the features controller is called, the app needs to be sure that everything has been updated in the database before displaying the list of features.

Should this be a background task that just runs every now and again? If so, how? Where should the code for this live? A rake/thor task?


one of the way to populate the database is "rake db:seed", you can add test-specific data with conditional expression "if Rails.env.test?"


So my approach is just going to be tossing up a rake task in lib/tasks. Has access to all my models and the like in there, so it seems like a good place to plop the code, which will slurp through the acceptance test repository, parse all the features files and populate the database. Maybe have a git hook that triggers this any time the test acceptance repository is updated (it's a git submodule), and call it good. If anyone has a better approach, I'd love to hear it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜