title: Capybara::ElementNotFound and ArgumentError
body: <p>I updated Rspec and now half of my Rspec tests are failing.</p>
  
  <p>Originally, all tests were failing, and I was able to get half of them to pass by adding "config.infer_spec_type_from_file_location!" to spec_helper.rb.</p>
  
  <p>The first type of error message is an Argument Error:</p>
  
  <pre><code>  1) todo_lists/new renders new todo_list form
   Failure/Error: assigns(:todo_list, stub_model(TodoList,
   ArgumentError:
     wrong number of arguments (2 for 0..1)
   # ./spec/views/todo_lists/new.html.erb_spec.rb:5:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>The second type is Capybara::ElementNotFound:</p>
  
  <pre><code>  5) Editing Todo Lists displays error when description is empty
   Failure/Error: fill_in "Title", with: options[:title]
   Capybara::ElementNotFound:
     Unable to find field "Title"
   # ./spec/features/todo_lists/edit_spec.rb:18:in `update_todo_lists'
   # ./spec/features/todo_lists/edit_spec.rb:55:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>My Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '4.1.4'
  gem 'sqlite3'
  gem 'sass-rails', '~&gt; 4.0.3'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.0.0'
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 2.0'
  gem 'sdoc', '~&gt; 0.4.0',          group: :doc
  
  gem 'spring',        group: :development
  
  group :development, :test do
    gem 'rspec-rails'
  end
  
  
  group :test do
    gem 'capybara'
    gem 'shoulda-matchers'
  end
  
  gem 'rspec-activemodel-mocks'
  </code></pre>
  
  <p>Spec_Helper File:</p>
  
  <pre><code>   ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  # require 'rspec/autorun'
  require 'capybara/rspec'
  require 'capybara/rails'
  
  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
  
  
  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
  
  RSpec.configure do |config|
    config.include TodoListHelpers, type: :feature
    config.include Capybara::DSL
  
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
  
    config.use_transactional_fixtures = true
  
    config.infer_base_class_for_anonymous_controllers = false
    config.infer_spec_type_from_file_location!
  
    config.order = "random"
  end
  
  module ::RSpec::Core
    class ExampleGroup
      include Capybara::DSL
      include Capybara::RSpecMatchers
    end
  end
  </code></pre>
  
  <p>todo_lists/new.html.erb_spec :</p>
  
  <pre><code>require 'spec_helper'
  
  describe "todo_lists/new" do
    before(:each) do
      assigns(:todo_list, stub_model(TodoList,
        :title =&gt; "MyString",
        :description =&gt; "MyText"
      ).as_new_record)
    end
  
    it "renders new todo_list form" do
      render
  
  # Run the generator again with the --webrat flag if you want to use webrat matchers
  assert_select "form[action=?][method=?]", todo_lists_path, "post" do
    assert_select "input#todo_list_title[name=?]", "todo_list[title]"
    assert_select "textarea#todo_list_description[name=?]", "todo_list[description]"
  
  
    end
    end
  end
  </code></pre>
  
  <p>features/todo_lists/edit_spec.rb</p>
  
  <pre><code>require 'spec_helper'
  
  describe "Editing Todo Lists" do
    let!(:todo_list) {TodoList.create(title:       "Groceries",
                                      description: "Grocery list")}
  
    def update_todo_lists(options={})
      options[:title] ||= "New Title"
      options[:description] ||= "New Description"
  
  todo_list = options[:todo_list]
  
  visit '/todo_lists'
  within "#todo_list_#{todo_list.id}" do
    click_link "Edit"
  end
  
  fill_in "Title", with: options[:title]
  fill_in "Description", with: options[:description]
  click_button "Update Todo list"
    end
  
    it "displays error when description is empty" do
  update_todo_lists todo_list: todo_list, description: ""
  description = todo_list.description
  
  todo_list.reload
  
  expect(page).to have_content("error")
  expect(todo_list.description).to eq(description)
  
  
  end
  </code></pre>
  
  <p>The edit view:</p>
  
  <pre><code>&lt;h1&gt;Editing todo_list&lt;/h1&gt;
  </code></pre>
  
  
  
   |
  
  
  <p>and the form helper:</p>
  
  <pre><code>&lt;%= form_for(@todo_list) do |f| %&gt;
    &lt;% if @todo_list.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@todo_list.errors.count, "error") %&gt; 
  
  `prohibited this todo_list from being saved:&lt;/h2&gt;`
  
    &lt;ul&gt;
    &lt;% @todo_list.errors.full_messages.each do |message| %&gt;
      &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
    &lt;% end %&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
    
  
  <pre><code>  &lt;div class="field"&gt;
      &lt;%= f.label :title %&gt;&lt;br&gt;
      &lt;%= f.text_field :title %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
  
  
     &lt;%= f.label :description %&gt;&lt;br&gt;
      &lt;%= f.text_area :description %&gt;
    &lt;/div&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>