[英]NoMethodError undefined method 'merge' when running RSpec integration test
I am following Micheal Hartl's Ruby on rails tutorial 2.3 Edition and I have followed the steps for the integration tests correctly.
我正在遵循Micheal Hartl的Ruby on Rails教程2.3版,并且已经正确执行了集成测试的步骤。 in
/sample_app/spec/integration I have a file named
layout_links_spec.rb which looks like this.
在/ sample_app / spec / integration中,我有一个名为
layout_links_spec.rb的文件,看起来像这样。
require 'spec_helper'
describe "Layout links" do
it "should have a Home page at '/'" do
get '/'
response.should render_template('pages/home')
end
end
When i do 当我做
$ spec spec/
I am getting the following error 我收到以下错误
1)
NoMethodError in 'Layout links should have a Home page at '/''
undefined method `merge' for nil:NilClass
/home/rails_projects/sample_app/spec/integration/layout_links_spec.rb:4:
Finished in 0.060225 seconds
1 example, 1 failure
Please help me with this error 请帮我解决这个错误
Based on this question, it looks to me like you are following the 1st edition of his tutorial. 基于这个问题,在我看来,您正在关注他的教程的第1版。 If so, the command he used to generate the integration test is on page 178, Section 5.2.1
如果是这样,他用来生成集成测试的命令在第178页的5.2.1节。
rails generate integration_test layout_links
The result is a file under spec/requests/layout_links_spec.rb 结果是spec / requests / layout_links_spec.rb下的文件
If you browse the source code for his app, there isn't a spec/integration folder. 如果您浏览他的应用程序的源代码,则没有spec / integration文件夹。 Take a look here and see if this helps.
在这里看看,是否有帮助。 Hope so.
希望如此。
PS: He comments "In RSpec, integration tests are also called request specs - the origins of this terminology are obscure to me." PS:他评论说:“在RSpec中,集成测试也称为请求规范 -该术语的起源对我来说是晦涩的。”
In the RSpec docs , I found this: Request specs provide a thin wrapper around Rails' integration tests, and are designed to drive behavior through the full stack, including routing (provided by Rails) and without stubbing (that's up to you). 在RSpec 文档中 ,我发现了这一点:请求规范为Rails的集成测试提供了一个薄薄的包装,并旨在在整个堆栈中推动行为,包括路由(由Rails提供)而没有存根(由您决定)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.