Reputation: 359
In my view spec i have the following
require 'spec_helper'
describe "my_project/index.html.erb" do
it "displays the Country drop down" do
render
rendered.should contain("Country")
end
end
But when i run the spec im getting the following error
Failure/Error: render
ActionView::Template::Error:
undefined method `map' for nil:NilClass
Im confused as to why am i getting this error when my page does actually contain the text.
Upvotes: 1
Views: 1003
Reputation: 2285
Do you need an instance variable for it to work with? I.e what ever is set up in the controller index method... So something like this:
require 'spec_helper'
describe "my_project/index.html.erb" do
before do
@some_instance_variable = SomeClass.all
render
end
it "displays the Country drop down" do
rendered.should contain("Country")
end
end
Upvotes: 2