私はこのチュートリアルに従っています: http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/そして私は問題を抱えています。このフォームを views/tasks/index.html.erb の下に作成しました
<%= form_for Task.new do |f| %>
<%= f.label :task %>
<%= f.text_field :task %>
<%= f.submit %>
<% end %>
次に、spec/controllers/tasks_controller_spec.rb に
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
これを Guard で実行すると、次のエラーが発生します。
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)>'
どうしたの?