简体   繁体   English

尝试在Rails上运行红宝石测试

[英]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.

相关问题 尝试使用 ruby​​ on rails 运行应用程序时出现控制器错误 - Controller error trying to run application with ruby on rails 如何使用 Unit::Test 在 Ruby on Rails 3.0.7 中运行单个测试? - How to run a single test in Ruby on Rails 3.0.7 using Unit::Test? Sequel::AdapterNotFound 尝试运行 Ruby On Rails 应用程序时 - Sequel::AdapterNotFound while trying to run Ruby On Rails application 尝试运行服务器时,Ruby on Rails postgres适配器错误 - Ruby on Rails postgres adapter error when trying to run the server 在Ruby on Rails中运行rake测试时出错 - Error when I run rake test in Ruby on Rails 每个测试在Ruby on Rails中运行需要多长时间? - How long does each test take to run in Ruby on Rails? 尝试创建单元测试(Ruby on Rails)时,Test和Rails控制台上的结果不同 - Different results on Test and in rails console when trying to create a unit test (Ruby on Rails) Rails 2.3.2单元测试在使用正常红宝石运行时通过,而在瑞克测试运行时失败: - Rails 2.3.2 unit test passes when run with normal ruby, fails when run with rake test:units 试图在导轨上安装 ruby - Trying to install ruby on rails 尝试在测试环境上运行RailsRunner时出现语法错误 - Syntax Error when trying to run rails runner on test environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM