目前在我的spec / decorators / product_decorator_spec.rb中,我有以下内容:
require 'spec_helper' describe ProductDecorator do let(:product) { FactoryGirl.create(:product) } subject do ProductDecorator.first end before do product end it 'should render the name attribute with a link to the product page' do subject.name.should == h.link_to(product.name,'test') end end
当我运行我的规范时,我得到以下内容:
F..... Failures: 1) ProductDecorator should render the name attribute with a link to the product page Failure/Error: subject.name.should == h.link_to(product.name,'resr') NameError: undefined local variable or method `h' for #<RSpec::Core::ExampleGroup::nested_2:0x007fbbf212c8b0> # ./spec/decorators/product_decorator_spec.rb:15:in `block (2 levels) in <top (required)>' Finished in 0.98531 seconds 6 examples,1 failure Failed examples: rspec ./spec/decorators/product_decorator_spec.rb:14 # ProductDecorator should render the name attribute with a link to the product page
根据文档,装饰器文件夹中的规范应该可以访问辅助方法,但是我的规范没有.我也试过手动标记我的规格,但似乎没有任何影响.
谢谢你的期待.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。