title: rails+rspec+capybara testing edit resource
body: <p>I have a test case:</p>
  
  <pre><code>#spec/features/post_spec.rb
  require 'spec_helper'
  
  describe "Posts" do
    subject { page }
  
    describe "edit" do
  
      post=FactoryGirl.create(:post)
      puts post.valid?
      puts post_path(post.id)
      puts post.id
  
      before { visit edit_post_path(post.id) }
      it {should have_content('Editing')}
      it {current_path.should == edit_post_path(post.id)}
  
    end
  end
  </code></pre>
  
  <p>I have a problem with the generation of URL by route system:</p>
  
  <pre><code>$rspec spec/features/posts_spec.rb 
  true
  81
  FF
  
  Failures:
  
    1) Posts edit 
       Failure/Error: before { visit edit_post_path(post.id) }
       ActionController::UrlGenerationError:
         No route matches {:action=&gt;"edit", :controller=&gt;"posts", :locale=&gt;81, :id=&gt;nil, :format=&gt;nil} missing required keys: [:id]
       # ./spec/features/2posts_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
    2) Posts edit 
       Failure/Error: before { visit edit_post_path(post.id) }
       ActionController::UrlGenerationError:
         No route matches {:action=&gt;"edit", :controller=&gt;"posts", :locale=&gt;81, :id=&gt;nil, :format=&gt;nil} missing required keys: [:id]
       # ./spec/features/2posts_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 0.00592 seconds
  2 examples, 2 failures
  
  Failed examples:
  
  rspec ./spec/features/2posts_spec.rb:15 # Posts edit 
  rspec ./spec/features/2posts_spec.rb:16 # Posts edit 
  
  Randomized with seed 6503
  </code></pre>
  
  <p>As you can see, the <code>id</code> param is not present in the generate link, and the locale param have the <code>id</code> param! 
  I have no idea. This is very Unattended behavior.</p>
  
  <p>UPDATE: 
  I have tried to use <code>post</code> instead <code>post.id</code> in <code>edit_post_path</code>.
  This is the result:</p>
  
  <pre><code>$rspec spec/features/posts_spec.rb 
  true
  83
  FF
  
  Failures:
  
    1) Posts edit 
       Failure/Error: before { visit edit_post_path(post) }
       ActionController::UrlGenerationError:
         No route matches {:action=&gt;"edit", :controller=&gt;"posts", :locale=&gt;#&lt;Post id: 83, title: "Vel Voluptas Veniam Ea Neque", autor: "Christina Rogahn", img_path: "Ut Iste Dolore", body: "Adipisci cupiditate eum eum deleniti facilis. Itaqu...", created_at: "2013-10-28 17:26:30", updated_at: "2013-10-28 17:26:31", email: "candelario@abernathy.name", user_id: 1&gt;, :id=&gt;nil, :format=&gt;nil} missing required keys: [:id]
       # ./spec/features/2posts_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
    2) Posts edit 
       Failure/Error: before { visit edit_post_path(post) }
       ActionController::UrlGenerationError:
         No route matches {:action=&gt;"edit", :controller=&gt;"posts", :locale=&gt;#&lt;Post id: 83, title: "Vel Voluptas Veniam Ea Neque", autor: "Christina Rogahn", img_path: "Ut Iste Dolore", body: "Adipisci cupiditate eum eum deleniti facilis. Itaqu...", created_at: "2013-10-28 17:26:30", updated_at: "2013-10-28 17:26:31", email: "candelario@abernathy.name", user_id: 1&gt;, :id=&gt;nil, :format=&gt;nil} missing required keys: [:id]
       # ./spec/features/2posts_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 0.00532 seconds
  2 examples, 2 failures
  
  Failed examples:
  
  rspec ./spec/features/2posts_spec.rb:14 # Posts edit 
  rspec ./spec/features/2posts_spec.rb:15 # Posts edit 
  
  Randomized with seed 32039
  </code></pre>
  
  <p>this is my routes.rb file:</p>
  
  <pre><code>#config/routes.rb
  SitoNegozio::Application.routes.draw do
    scope "(:locale)", locale: /it|en/ do
  
    devise_for :users , controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
  
    resources :users
    resources :posts do
      resources :msgs
    end
  
    root :to =&gt; 'static_pages#index'
  
    end
  end
  </code></pre>
  
  <p><strong><em>SOLVED:</em></strong></p>
  
  <pre><code>#https://github.com/rspec/rspec-rails/issues/255#issuecomment-24698753
    config.before(:each, type: :feature) do
      default_url_options[:locale] = I18n.default_locale
    end
  </code></pre>