2013-07-20 2 views
1

이 자습서와 함께 다음을 수행하고 있습니다 : http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ 문제가 있습니다. 나는 가드로, 나는이 실패를 얻을 내가 실행할 때 내가필드 레일을 찾을 수 없습니다.

require 'spec_helper' 

describe TasksController do 

    describe "GET 'index'" do 
    it "returns http success" do 
     @task = Task.create :task => 'go to bed' 

     get 'index' 
     response.should be_success 
    end 

    it "creates a new task" do 
     visit tasks_path 
     fill_in 'Task', :with => 'go to work' 
     click_button 'Create Task' 

     current_path.should == tasks_path 
     page.should have_content 'go to work' 
     save_and_open_page 
    end 
end 

end 

이 사양/컨트롤러/tasks_controller_spec.rb에

<%= form_for Task.new do |f| %> 
    <%= f.label :task %> 
    <%= f.text_field :task %> 
    <%= f.submit %> 
<% end %> 

다음 뷰/작업/index.html.erb에서이 양식을 작성 :

Failures: 

    1) TasksController GET 'index' creates a new task 
    Failure/Error: fill_in 'Task', :with => 'go to work' 
    Capybara::ElementNotFound: 
     Unable to find field "Task" 
    # ./spec/controllers/tasks_controller_spec.rb:15:in `block (3 levels) in <top (required)>' 

무엇이 잘못 되었습니까?

+0

나는 하나의 파일에 뷰와 컨트롤러 코드를 생성한다고 생각한다. –

+0

그게 무슨 뜻이야? 내가 말했듯이 그들은 분리 된 파일에있다. – Phil

+0

그것이 작동하지 않는 이유는 모르겠지만 튜토리얼 소스와 비교할 때'Task.new' 대신'@ task' 컨트롤러 인스턴스 변수를 사용해야합니다. –

답변

-1

잘 모르겠지만 컨트롤러의 "if"문이라고 가정합니다. 당신이 그들을 "그것"으로 썼기 때문에.

+0

"if"로 변경하면 더 나빠질 것 같습니다. 튜토리얼에 따르면, "it"이어야합니다. – Phil

+1

그건 사양이 아니고 컨트롤러가 아니기 때문에 rspec 스타일의 "describe-it"구문을 사용하고 있습니다. –

+0

Doh! 미안, 서둘러. 더주의를 기울여야 만합니다. 사과! –