0

我是一名 Rails 新手,正在研究我的 RSpec 技能。我遇到了这个未定义的错误,这让我摸不着头脑。这里是:

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

下面是我的规范文件。你能告诉我我在这里俯瞰什么吗?

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
4

1 回答 1

2

Movies是一个类,因此不具有 的值location。您应该检查: 、、或location的实例。例如:Moviesmovie1234

expect(page).to have_text(movie1.location)
于 2013-09-06T17:17:40.140 回答