Tag: 整合测试

capybara:page.should have_no_content对display:none元素无法正常工作

我想使用page.should have_no_content来检查页面是否没有向用户显示标签,这里是HTML中的内容: My Account … 因此,当我使用page.should have_no_content(“我的帐户”)时,它返回false而不是true。

用selenium作为webdriver的Rails集成测试 – 不能sign_in

你好 我有一个非常简单的集成测试 require ‘integration_test_helper’ Capybara.current_driver = :rack_test class AdminSignsInTest < ActionDispatch::IntegrationTest test 'can sign in' do email = 'bob@example.com' password = 'secret_password' Admin.create email: email, password: password visit new_admin_session_path fill_in 'admin_email', with: email fill_in 'admin_password', with: password click_button I18n.t('devise.views.sign_in') assert_equal I18n.t('devise.sessions.signed_in'), find('p.notice').text end end 当我将rack_test驱动程序设置为rack_test测试通行证时,但当我将其设置为selenium ,它会因“电子邮件或密码无效”而失败。 在登录页面上(我正在使用Devise)。 我究竟做错了什么?

Rails助手不在测试环境中工作

我已经按照http://railscasts.com/episodes/221-subdomains-in-rails-3上的教程进行了操作。 它允许您通过覆盖帮助文件中的url_for方法将子域选项传递给路由。 我的帮手方法看起来像这样: module UrlHelper def with_subdomain(subdomain) subdomain = (subdomain || “”) subdomain += “.” unless subdomain.empty? [subdomain, request.domain, request.port_string].join end def url_for(options = nil) if options.kind_of?(Hash) && options.has_key?(:subdomain) options[:host] = with_subdomain(options.delete(:subdomain)) end super end end 所以: sites_homepage_url(:subdomain => “cats”) 生成url: “http://cats.example.com/sites/1/homepage” 这在开发中工作得很好。 然而,在我的黄瓜测试中,使用: sites_homepage_url(:subdomain => “cats”) 生产: “http://www.example.com/sites/1/homepage?subdomain=cats” 这表示我在助手中添加到url_for的function不起作用。 有人有任何想法吗? 编辑:格式化并添加UrlHelper的代码。