Srivathsa
Srivathsa

Reputation: 961

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. in /sample_app/spec/integration I have a file named layout_links_spec.rb which looks like this.

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

Upvotes: 2

Views: 929

Answers (1)

memoht
memoht

Reputation: 781

Based on this question, it looks to me like you are following the 1st edition of his tutorial. If so, the command he used to generate the integration test is on page 178, Section 5.2.1

rails generate integration_test layout_links

The result is a file under spec/requests/layout_links_spec.rb


If you browse the source code for his app, there isn't a spec/integration folder. 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."

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).

Upvotes: 1

Related Questions