ruby-on-rails – 我可以在RSpec请求中访问Application Helper方
发布时间:2020-12-16 20:01:54 所属栏目:百科 来源:网络整理
导读:鉴于我在ApplicationHelper模块中有一个full_title方法,如何以RSpec请求规范进行访问? 我现在有以下代码: 应用程序/佣工/ application_helper.rb module ApplicationHelper # Returns the full title on a per-page basis. def full_title(page_title) bas
鉴于我在ApplicationHelper模块中有一个full_title方法,如何以RSpec请求规范进行访问?
我现在有以下代码: 应用程序/佣工/ application_helper.rb module ApplicationHelper # Returns the full title on a per-page basis. def full_title(page_title) base_title = "My Site title" logger.debug "page_title: #{page_title}" if page_title.empty? base_title else "#{page_title} - #{base_title}" end end 规格/请求/ user_pages_spec.rb require 'spec_helper' describe "User Pages" do subject { page } describe "signup page" do before { visit signup_path } it { should have_selector('h2',text: 'Sign up') } it { should have_selector('title',text: full_title('Sign Up')) } end end 在运行此规范时,我收到此错误消息: NoMethodError: 根据Michael Hartl的Rails Tutorial的测试,我应该能够访问我的用户规范中的应用程序帮助程序.我在这里犯了什么错? 解决方法
按照列表5.26中的规范/ support / utilities.rb创建帮助器.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |