Ruby on rails 在静态数据库中使用Cucumber
我正在尝试对已经填充了数据的数据库运行Cucumber测试。它基本上是我们生产数据库的副本 出于某种原因,我有一些测试失败,这似乎是因为它找不到数据。有没有关于如何使这项工作以及为什么它不喜欢“预种子”数据库的想法 我们的数据太复杂,无法通过工厂/固定装置重新创建。没有办法 下面是一个例子:Ruby on rails 在静态数据库中使用Cucumber,ruby-on-rails,database,oracle,cucumber,bdd,Ruby On Rails,Database,Oracle,Cucumber,Bdd,我正在尝试对已经填充了数据的数据库运行Cucumber测试。它基本上是我们生产数据库的副本 出于某种原因,我有一些测试失败,这似乎是因为它找不到数据。有没有关于如何使这项工作以及为什么它不喜欢“预种子”数据库的想法 我们的数据太复杂,无法通过工厂/固定装置重新创建。没有办法 下面是一个例子: Scenario: a tech logs in
Scenario: a tech logs in
Given I am on the login page
And user with id 2328 exists
When I login as "user" with password "password"
Then I should be on the dashboard page
And I should see "Logged in as: USER"
步骤如下:
Given /^user with id (\d+) exists$/ do |id|
Employee.exists? id
end
When /^I login as "([^\"]*)" with password "([^\"]*)"$/ do |username, password|
visit login_url
fill_in "username", with: username
fill_in "pwd", with: password
click_button "Login"
end
也许这是我的步骤,与数据库无关,但我不明白为什么它在上没有失败,当我给它一个错误的数字时,id为2328的用户仍然存在
我已经看到了,但它似乎并不影响流量
最后,这里是实际的登录方法(相信我,我知道这个登录检查有多糟糕,只需检查我们对数据库的权限):
每次跑步,我都会得到:
expected: "/dashboard",
got: "/login" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:198:in `/^(?:|I )should be on (.+)$/'
features/tech_queue.feature:11:in `Then I should be on the dashboard page'
在user with:id exists
步骤中放置一些调试(例如放置),以显示用户是否存在。还要添加一个步骤,然后显示页面
(确保安装了启动
gem),以查看Cucumber测试的页面。这允许您查看登录屏幕上是否显示任何错误。它肯定会出现在登录页面上,但不会显示错误消息。同样,它也会对用户的存在进行验证,但这对成功或失败的条件没有影响,这真的很奇怪。测试和id为X的用户存在,当X为有效或无效数字时,测试通过。黄瓜虫??
expected: "/dashboard",
got: "/login" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:198:in `/^(?:|I )should be on (.+)$/'
features/tech_queue.feature:11:in `Then I should be on the dashboard page'