[英]Trying to run a ruby on rails test
%table.table-hover{}
%thead
%tr
%th Registration NO.
%th Name
%th Tier
%th Email
%tbody
- @accounts.each do |user|
%tr{:onclick => "window.location='/accounts/#{user[:id]}';"}
%td #{user.id}
%td #{user.givenname}
- if user.admin?
%td Admin
- elsif user.tech?
%td Technician
- else
%td User
%td #{user.email}
This is the code for page, so when you click on a row in the table table , then it should jump another page which is the details about this row. 这是页面的代码,因此当您单击表table中的一行时,它应该跳到另一页,这是有关该行的详细信息。 detail page And here are my test code.
详细页面这是我的测试代码。
require 'rails_helper'
RSpec.describe 'accounts' do
context :js => true do
before do
@testAdmin = FactoryGirl.create(:admin)
end
describe 'Account Page can' do
before do
login_as(@testAdmin, :scope => :account)
visit '/accounts'
end
specify "visit account page" do
page.find(:xpath, "//table/tbody/tr").click
expect(page).to have_content 'Account: testAdmin'
end
end
end
end
When I run and printed out the page, it appears it's still on the table page, which means it does not jumped to the details page. 当我运行并打印出页面时,它似乎仍在表格页面上,这意味着它没有跳到详细信息页面。
As pointed out by @Daniel, your context
line doesn't have any description text in it. 正如@Daniel指出的那样,您的
context
行中没有任何描述文字。 This means :js => true
will be taken as the name of the context block and not used as metadata to switch to the JS capable driver. 这意味着
:js => true
将用作上下文块的名称,而不用作切换到支持JS的驱动程序的元数据。 This should have been noticeable from the name of the failed test which would have been something like accounts {:js=>true} Account Page can visit account page
. 从失败测试的名称中应该可以注意到这一点,例如
accounts {:js=>true} Account Page can visit account page
。 To fix you should just need to include descriptive text in the context
call 要解决此问题,您只需要在
context
调用中包含描述性文本
context "something", js: true
or just dump the context block and apply the metadata to whichever of the other blocks makes sense 或仅转储上下文块并将元数据应用于其他任何有意义的块
describe 'Account Page can', js: true do
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.