2013-09-06 2 views
0

저는 RSpec 스킬에 대한 Rails 초보자입니다. 나는 내 머리를 긁적 거리고있는이 정의되지 않은 오류를 겪고있다. 여기에 있습니다 :정의되지 않은 메소드 혼동

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 
+0

'location'은 클래스 메소드가 아니라 * instance * 메소드입니다. 특정 영화의 위치 등을 참조해야합니다. –

답변

2

Movieslocation 값이없는, 따라서 클래스입니다. locationMovies의 인스턴스 인 movie1, 2, 3 또는 4과 대조해야합니다. 예 :

expect(page).to have_text(movie1.location) 
관련 문제