이 자습서와 함께 다음을 수행하고 있습니다 : 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)>'
무엇이 잘못 되었습니까?
나는 하나의 파일에 뷰와 컨트롤러 코드를 생성한다고 생각한다. –
그게 무슨 뜻이야? 내가 말했듯이 그들은 분리 된 파일에있다. – Phil
그것이 작동하지 않는 이유는 모르겠지만 튜토리얼 소스와 비교할 때'Task.new' 대신'@ task' 컨트롤러 인스턴스 변수를 사용해야합니다. –