Reputation: 11
I'm a Rails newbie working on my RSpec skills. I'm running into this undefined error that's leaving me scratching my head. Here it is:
1) Veiwing the list of movies shows the movies
Failure/Error: expect(page).to have_text(Movies.location)
NoMethodError:
undefined method `location' for #<Class:0x00000104bbb958>
# ./spec/features/list_movies_spec.rb:26:in `block (2 levels) in <top (required)>
Below is my spec file. Can you please tell me what am I overlooking here?
require "spec_helper"
feature "Veiwing the list of movies" do
it "shows the movies" do
movie1 = Movies.create(name: "The Butler", location: "New York City",
price:15.00)
movie2 = Movies.create(name: "The Grand Master", location: "New Jersey",
price:15.00)
movie3 = Movies.create(name: "Elysium", location: "Los Angeles",
price:15.00 )
movie4 = Movies.create(name:"Pacific Rim", location: "Queens NY",
price:15.00)
visit movies_url
expect(page).to have_text("4 Movies")
expect(page).to have_text(Movies.name)
expect(page).to have_text(Movies.name)
expect(page).to have_text(Movies.name)
expect(page).to have_text(Movies.name)
expect(page).to have_text(Movies.location)
expect(page).to have_text(Movies.description)
expect(page).to have_text("15.00")
end
end
Upvotes: 0
Views: 89
Reputation: 5249
Movies
is a class and thus does not have a value for location
. You should be checking the location
against an instance of Movies
: movie1
, 2
, 3
, or 4
. For example:
expect(page).to have_text(movie1.location)
Upvotes: 2