Rails:不同环境的特定 rake 任务依赖关系
我的主 rakefile 有一些任务来停止和启动 selenuim,如下所示:
require 'selenium/rake/tasks'
Selenium::Rake::RemoteControlStartTask.new do |rc|
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
rc.background = false
rc.wait_until_up_and_running = true
rc.additional_args << "-singleWindow"
end
Selenium::Rake::RemoteControlStopTask.new do |rc|
rc.host = "localhost"
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
end
这强制要求安装 selenuim gem 才能使用 rake,无论 轨道环境。我可以在哪里放置此代码,以便仅在将 Rails 环境设置为测试时才加载它?
Rails 2.3
干杯
My main rakefile has some tasks to stop and start selenuim as follows:
require 'selenium/rake/tasks'
Selenium::Rake::RemoteControlStartTask.new do |rc|
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
rc.background = false
rc.wait_until_up_and_running = true
rc.additional_args << "-singleWindow"
end
Selenium::Rake::RemoteControlStopTask.new do |rc|
rc.host = "localhost"
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
end
This forces the requirement to have the selenuim gem installed to use rake regardless of the
rails environment. Where can I put this code so it will only be loaded when the rails environment is set to test?
Rails 2.3
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是 Rails 3 还是 Rails 2?
Rails 3 添加了如下所示的块:
在 Rails 2(或 3,但已弃用)中,如下所示:
Are you using Rails 3 or Rails 2?
Rails 3 add a blocks like so:
In Rails 2 (or 3 but it's deprecated) like this: