黄瓜:即使我在命令行指定 RAILS_ENV=test 也使用 dev db
database.yml 的相关部分:
development:
adapter: mysql
encoding: utf8
database: dev
username: root
password:
test: &TEST
adapter: mysql
encoding: utf8
database: test
username: root
password:
cucumber:
<<: *TEST
culerity:
<<: *TEST
因此,似乎每当 cucumber 与浏览器交互时,它都会修改开发数据库。但是当我以编程方式执行操作(例如添加默认用户登录)时,它会修改测试数据库。
为什么测试环境会响应 ruby/rails 请求,但在视图测试运行时切换到 dev?
这就是我运行 cucumber: 的方式,
$> bundle exec rake test:cucumber:authentication
它运行此文件中的任务:
begin
require 'rubygems'
ENV["RAILS_ENV"]="test"
require 'cucumber'
require 'cucumber/rake/task'
namespace :test do
namespace :cucumber do
Cucumber::Rake::Task.new(:authentication) do |t|
t.cucumber_opts = "features/Authentication.feature"
end
...
relevant part of database.yml:
development:
adapter: mysql
encoding: utf8
database: dev
username: root
password:
test: &TEST
adapter: mysql
encoding: utf8
database: test
username: root
password:
cucumber:
<<: *TEST
culerity:
<<: *TEST
So, it seems that whenever cucumber interacts with the browser, it modifies the development database. But when I do things programmatically (such as adding a default user to login), it modifies the test database.
Why would the test env me responding to ruby/rails requests, but switches over to dev when the view-tests are running?
This is how I'm running cucumber:
gt; bundle exec rake test:cucumber:authentication
which runs the task in this file:
begin
require 'rubygems'
ENV["RAILS_ENV"]="test"
require 'cucumber'
require 'cucumber/rake/task'
namespace :test do
namespace :cucumber do
Cucumber::Rake::Task.new(:authentication) do |t|
t.cucumber_opts = "features/Authentication.feature"
end
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论