我对rails非常陌生,并试图遵循railstutorial.一切都很顺利,除了我的测试无法通过命名路线(5.3.3)
我的routes.rb:
SampleApp::Application.routes.draw do
resources :users
match '/signup', to: 'users#new'
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'pages#contact'
root to: 'static_pages#home'
#Commented stuff
Run Code Online (Sandbox Code Playgroud)
我的第一次测试(spec/controllers/static_pages_controller_spec.rb):
describe "Static pages" do
subject { page }
shared_examples_for "all static pages" do
it { should have_selector('h1', text: heading) }
it { should have_selector('title', text: full_title(page_title)) }
end
describe "Home page" do
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { 'Home' }
it_should_behave_like "all static pages"
end
#Other …Run Code Online (Sandbox Code Playgroud)