<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>omobh (OMOBH)</title>
    <link>https://ruby-china.org/omobh</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>rspec 测试问题，无法找到具名路由</title>
      <description>&lt;p&gt;在照着 Ruby on Rails 教程做，但是到了 5.3.2 路由一章做不过去了，就是在 routes 中把静态路径改成 match 后，浏览器可以正常访问，但是 rspec 中 visit 改成 root_path 后，就全部访问不到了，测试全错，郁闷
为啥阿～～
我的文件内容：
routes:&lt;/p&gt;

&lt;p&gt;SampleApp::Application.routes.draw do
    root :to =&amp;gt; 'static_pages#home'
  match '/help', to: 'static_pages#help', via: 'get'
  match '/contact', to: 'static_pages#contact', via: 'get'
  match '/about', to: 'static_pages#about', via: 'get'
 end&lt;/p&gt;

&lt;p&gt;spec:&lt;/p&gt;

&lt;p&gt;require 'spec_helper'&lt;/p&gt;

&lt;p&gt;describe "StaticPages" do
  describe "Home page" do
    it "should have the content 'Sample App'" do
        visit root_path 
        expect(page).to have_content('Sample App')
    end
        it "should have the title Home" do
            visit root_path
            expect(page).to have_title('Ruby on Rails Tutorial Sample App | Home')
        end
    end
end&lt;/p&gt;

&lt;p&gt;Gemfile:
source '&lt;a href="https://rubygems.org" rel="nofollow" target="_blank"&gt;https://rubygems.org&lt;/a&gt;'
gem 'rails', '4.1.8'
gem 'bootstrap-sass'
gem 'minitest'
group :development, :test do
    gem 'sqlite3'
    gem 'spork-rails', github: 'railstutorial/spork-rails'
    gem 'guard-rspec'
    gem 'guard-spork'
    gem 'rspec-rails' 
    gem 'childprocess', '0.3.6'
end
group :test do
    gem 'selenium-webdriver', '2.35.1'
    gem 'capybara', '2.2.0'
end
gem 'sass-rails', '~&amp;gt; 4.0.3'
gem 'uglifier', '&amp;gt;= 1.3.0'
gem 'coffee-rails', '~&amp;gt; 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~&amp;gt; 2.0'
group :doc do
    gem 'sdoc', '~&amp;gt; 0.4.0', require: false 
end &lt;/p&gt;
&lt;h2 id="Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring"&gt;Spring speeds up development by keeping your application running in the background. Read more: &lt;a href="https://github.com/rails/spring" rel="nofollow" target="_blank"&gt;https://github.com/rails/spring&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;gem 'spring',        group: :development&lt;/p&gt;</description>
      <author>omobh</author>
      <pubDate>Sat, 20 Dec 2014 21:43:25 +0800</pubDate>
      <link>https://ruby-china.org/topics/23305</link>
      <guid>https://ruby-china.org/topics/23305</guid>
    </item>
  </channel>
</rss>
